Problème d'Installation avec matplotlib Python [dupliquer]

Cette question a déjà une réponse ici:

J'ai un problème après l'installation du Paquetmatplotlib impossible d'importer matplotlib.pyplot comme plt . Toute suggestion sera grandement apprécier.

>>> import matplotlib.pyplot as plt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/pyplot.py", line 98, in <module>
    _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/__init__.py", line 28, in pylab_setup
    globals(),locals(),[backend_name],0)
  File "//anaconda/lib/python2.7/site-packages/matplotlib-1.3.1-py2.7-macosx-10.5-x86_64.egg/matplotlib/backends/backend_macosx.py", line 21, in <module>
    from matplotlib.backends import _macosx
**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.
368
demandé sur J4cK 2014-02-14 20:34:07

1 réponses

Cause Du Problème Dans Mac OS image rendering back end de matplotlib (what-is-a-backend pour rendre en utilisant L'API de Cocoa par défaut). Il y a Qt4Agg et GTKAgg et comme back-end n'est pas la valeur par défaut. Définissez l'extrémité arrière de macosx qui diffère par rapport aux autres systèmes d'exploitation windows ou linux.

Je résous ce problème de la manière suivante:

  • je suppose que vous avez installé le PIP matplotlib, il y a un répertoire dans votre racine appelé ~/.matplotlib.
  • créez un fichier ~/.matplotlib/matplotlibrc là et ajouter le code suivant: backend: TkAgg

À partir de ce lien Vous pouvez essayer un diagramme différent.

1049
répondu J4cK 2018-01-12 18:47:48