`

from matplotlib import pyplot 时报错 Python is not installed as a framework

阅读更多
当引用pyplot时 (from matplotlib import pyplot), 报如下错误

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

有两种解决方案:

1) 在引用pyplot之前,指定TkAgg
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot

2) 在环境中设置指定TkAgg

打开文件:  vim  ~/.matplotlib/matplotlibrc
添加: backend: TkAgg
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics