无法在M上的pippinstalled Python中导入pyplot

2024-04-25 09:20:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我pip安装了python和matplotlib,但是当我输入命令“importmatplotlib.pyplot作为plt”,即使在~/.matplotlib目录中创建matplotlibrc文件(它原来不在那里)之后,我仍然得到下面的错误,行为“backend:TKAgg”

RuntimeError                     Traceback (most recent call last)
<ipython-input-17-eff513f636fd> in <module>()
----> 1 import matplotlib.pyplot as plt

/Users/guoj/miniconda2/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
    112 
    113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    115 
    116 _IP_REGISTERED = None

/Users/guoj/miniconda2/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
     30     # imports. 0 means only perform absolute imports.
     31     backend_mod = __import__(backend_name,
---> 32                              globals(),locals(),[backend_name],0)
     33 
     34     # Things we pull in from all backends

/Users/guoj/miniconda2/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in <module>()
     22 
     23 import matplotlib
---> 24 from matplotlib.backends import _macosx
     25 

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 Working with Matplotlib in a virtual enviroment see 'Working 
with Matplotlib in Virtual environments' in the Matplotlib FAQ

Tags: inimportbackendmatplotliblibpackagesassite