![](/img/trans.png)
[英]matplotlib: RuntimeError: Python is not installed as a framework
[英]Python via Conda on Mac OS X: RuntimeError: Python is not installed as a framework
我在 Mac 10.14.6 上运行,到目前为止我尝试过的所有解决方案都没有奏效。 我正在关注OpenAI spinup的文档并被困在这条线上:
python -m spinup.run plot data/installtest/installtest_s0
在尝试导入 matplotlib 和 plot 一些图表时,我不断得到:
文件 /anaconda3/envs/spinningup2/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py",第 14 行,来自 matplotlib.backends import _macosx ImportError: ZA7F5F35426B927411FC9231B563817 未安装为框架。 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后端。如果您使用的是 (Ana)Conda,请安装 python.app 并将“python”的使用替换为“pythonw”。有关更多信息,请参阅 Z1587383CF8C21507D06FB51EF7 中的“在 OSX 上使用 Matplotlib”。
在网上搜索后,我发现这是一个很常见的问题,所以这是我迄今为止尝试过的:
1. https://github.com/scikit-optimize/scikit-optimize/issues/637
添加
import matplotlib
matplotlib.use('PS')
在导入matplotlib.pyplot
之前
我仍然有同样的错误。
而不是from matplotlib import pyplot as plt
我使用了:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
但是我仍然遇到同样的错误。
3. matplotlib: RuntimeError: Python 没有作为框架安装
添加一行:
backend: TkAgg
在文件中:
~/.matplotlib/matplotlibrc
这不能解决我的问题,我有同样的错误
4.
我尝试在 ~/.matplotlib/matplotlibrc 创建一个文件并使用以下文本填充它:
$ cat ~/.matplotlib/matplotlibrc
backend: TkAgg
使用cat
命令时,这会以某种方式使我的 MAC 崩溃并导致重新启动。 我很困扰。
任何帮助或建议将不胜感激。 我已经尝试了我在这个网站上找到的所有建议,但没有运气。
我能够通过卸载 matplotlib 来解决这个问题,然后使用 Conda 重新安装我需要的确切版本(可能是 3.0.3)。
我还注意到,Conda 安装了六个 (six-1.15.0-py37hecd8cb5_0) 作为其中的一部分,所以不确定罪魁祸首是什么,但现在已修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.