Ich habe Anaconda mit dem Installer installiert.
Python 2.7.10 |Continuum Analytics, Inc.| (default, May 28 2015, 17:04:42)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
wenn ich jedoch versuche, etwas von Matplotlib zu verwenden, d. h .:
from matplotlib import pyplot as plt
Ich bekomme
RuntimeError: Python is not installed as a framework.
The Mac OS X backend will not be able to function correctly if Python is not installed
as a framework. See the Python documentation for more information on installing Python
as a framework on Mac OS X. Please either reinstall Python as a framework,
or try one of the other backends.
Ich bin wirklich nicht sicher, was das bedeutet oder wie man es reparieren kann.
Wenn dieser Fehler auftritt, vergessen Sie nicht, Ihr bash_profile zu überprüfen.
Sie können dies im Terminal tun durch:
cd
dann
nano .bash_profile
Überprüfen Sie den Inhalt. Macports und Homebrew fügen ihre eigenen Überschriften für Dinge hinzu, die sie hier gemacht haben. Sie können die Deklarationen entfernen, die sie an $ PATH abgeben. Lassen Sie einfach das, was Anaconda gemacht hat. Ich hatte ein Wenn Sie möchten, können Sie:
cp .bash_profile ./bash_profile_backup_yyyy_mm_dd
und haben Sie eine Sicherungskopie der Datei. Der Dateiname wird bis zu dem Datum indiziert, an dem Sie die Datei geändert haben. Das heißt, vorausgesetzt, Sie geben tatsächlich das Datum ein und nicht nur die Formatierungszeichen, die ich vorschlage.
source ~/.bash_profile
aktualisiert den Verweis Ihres Systems auf das bash_profile, und Sie sollten gut mit Matplotlib importieren und arbeiten
Ich hatte das gleiche Problem mit Anaconda 2 & Matplotlib 1.5.3.
Einen einfachen conda install matplotlib
auszuführen, um matplotlib neu zu installieren, war für mich der Trick.
Posting, da ich gerade dieses Problem hatte und dies eine schnelle Lösung war:
Wenn Sie pip zum Installieren verwendet haben:
~/.matplotlib/matplotlibrc
erstellen
Fügen Sie der Datei "backend: TkAgg
" (ohne die Anführungszeichen) hinzu.
Wenn das Problem nur matplotlib ist, lohnt es sich, das Backend zu ändern:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
Wenn es funktioniert, können Sie das Backend dauerhaft aus der matplotlibrc-Datei ändern.
Führen Sie die Datei mit pythonw
anstelle von python
..__ aus, da Python nicht als Framework installiert ist. Verwenden Sie daher pythonw myScript.py
anstelle von python myScript.py
Ich bin sicher, dass dies behoben wird.
Ich hatte einen ähnlichen Fehler .RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
Ich hatte das gleiche Problem. Die Installation einer älteren Version von matplotlib hat für mich den Trick gebracht. Probieren Sie diesen Befehl in Ihrem Terminal aus, während Sie sich in Ihrer virtuellen Umgebung befinden:
pip install matplotlib==1.4.3
Aus der matplotlib Dokumentation ;
$ conda install python.app
Sie benötigen einen Framwork-Build aus Python für Matplotlib, aber
Der in (Ana) conda bereitgestellte Standard-Python ist kein Framework-Build. Ein Framework-Build kann jedoch sowohl in der Hauptumgebung als auch in conda envs problemlos installiert werden: Installieren Sie python.app (conda install python.app) und verwenden Sie pythonw anstelle von python
NB: Ich musste den conda-forge
-Kanal hinzufügen, da python.app
nicht in den Standard-Miniconda-Kanälen enthalten ist
$ conda config --add channels conda-forge
Eine Neuinstallation von matplotlib sollte das Problem für Sie beheben, wie es bei mir der Fall war
conda install matplotlib
wenn Sie in einer virtuellen Umgebung verwenden, empfehle ich, die folgenden Anweisungen zu befolgen: http://matplotlib.org/faq/virtualenv_faq.html
Quickfix: Führen Sie Ihre Datei mit pythonw anstelle von python aus.
z.B. pythonw testFile.py.