web-dev-qa-db-fra.com

Erreur d'exécution Anaconda: Python n'est pas installé en tant que framework?

J'ai installé Anaconda avec l'installateur pkg:

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

mais quand j'essaye d'utiliser quelque chose de matplotlib, c'est à dire:

 from matplotlib import pyplot as plt

Je reçois 

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.

Je ne sais vraiment pas ce que cela signifie ni comment y remédier.

23
Mark Brown

Si vous rencontrez cette erreur, n'oubliez pas de vérifier votre bash_profile. 

Vous pouvez le faire dans le terminal en:

cd

puis

nano .bash_profile

vérifier le contenu. Macports et Homebrew ajoutent leurs propres titres pour ce qu'ils ont fait ici. Vous pouvez supprimer les déclarations qu'ils font à $ PATH. Laissez juste celui qu'Anaconda a fait. J'ai eu un Si vous voudriez, vous pouvez:

cp .bash_profile ./bash_profile_backup_yyyy_mm_dd 

et avoir une sauvegarde du fichier, avec l'indexation du nom de fichier à la date à laquelle vous l'avez changé. En d’autres termes, à condition que vous inscriviez la date au lieu des caractères de formatage que je propose. 

source ~/.bash_profile

actualisera la référence de votre système au bash_profile et vous devriez être prêt à importer et utiliser matplotlib

0
Mark Brown

J'avais le même problème avec anaconda 2 & matplotlib 1.5.3.

Exécuter un simple conda install matplotlib pour réinstaller matplotlib a été l’astuce pour moi. 

31
dangom

Publier depuis que je viens d'avoir ce problème et c'était une solution rapide:

Si vous avez utilisé pip pour installer: 

  1. Créer ~/.matplotlib/matplotlibrc 

  2. Ajoutez "backend: TkAgg" (sans les citations) au fichier.

28
Jared Wilber

Si le problème est seulement matplotlib, vaut la peine d'essayer de changer le backend:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

plt.plot([1, 2, 3], [4, 5, 6])
plt.show()

Si cela fonctionne, vous pouvez modifier le backend de manière permanente à partir du fichier matplotlibrc.

13
SeF

Exécutez le fichier en utilisant pythonw au lieu de python. Cela se produit car python n'est pas installé en tant qu'infrastructure. Par conséquent, utilisez pythonw myScript.py au lieu de python myScript.py Je suis sûr que cela résoudra le problème. 

J'ai eu une erreur similaire .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.

7
devssh

J'avais le même problème. L'installation d'une version plus ancienne de matplotlib a été l'affaire de moi. Essayez cette commande dans votre terminal dans votre environnement virtuel:

pip install matplotlib==1.4.3
6
Glenn Cameron

À partir de documentation matplotlib

$ conda install python.app

Vous avez besoin d’une compilation de Python pour matplotlib, mais

Le python par défaut fourni dans (Ana) conda n'est pas une construction de framework. Cependant, une construction de framework peut être facilement installée, à la fois dans l'environnement principal et dans les envois: installer python.app (conda install python.app) et utiliser pythonw plutôt que python

NB: j'ai dû ajouter le canal conda-forge car python.app n'est pas inclus dans les canaux par défaut de miniconda

$ conda config --add channels conda-forge

1
danodonovan

Une réinstallation de matplotlib devrait résoudre le problème pour vous comme il l’avait 

conda install matplotlib

0
Cory Watts

Quickfix: Exécutez votre fichier en utilisant pythonw, au lieu de python. 

par exemple, pythonw testFile.py.

0
Sehul Viras