RuntimeError: Python is not installed as a framework

问题描述

引入 matplotlib 的时候

import matplotlib.pyplot as plt

报错如下:

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
...

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

解决方法

进入目录: ~/.matplotlib

创建一个名为matplotlibrc的文件,内容是:

backend: TkAgg

参考:

RuntimeError: Python is not installed as a framework 错误解决方案

猜你喜欢

转载自blog.csdn.net/mouday/article/details/80219847