您的位置:首页 > 编程语言 > Python开发

【Python】Macbook Pro MacOS Sierra 无法加载 matplotlib.pyplot 解决办法

2017-06-17 22:58 639 查看
错误提示内容:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py", line 114, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/Applications/anaconda/lib/python2.7/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/Applications/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py", line 24, 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. If you are Working with Matplotlib in a virtual
enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ


找到两种解决办法,第一方法我用不好使,第二个方法我用好使。

第一种方法:

cd ~./matplotlib
fc-list
老外说会运行10到15分钟,所以如果上面命令可行就耐心等一等。反正这个方法对我没用。

转自:https://github.com/matplotlib/matplotlib/issues/2919

第二种方法:

cd ~/.matplotlib
nano matplotlibrc
添加内容:

backend : Agg
按Shift + C,按Y,按回车退出。

转自:https://stackoverflow.com/questions/29433824/unable-to-import-matplotlib-pyplot-as-plt-in-virtualenv
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: