简体   繁体   English

Python 在 Mac OS X 上通过 Conda:RuntimeError: Python 未作为框架安装

[英]Python via Conda on Mac OS X: RuntimeError: Python is not installed as a framework

I am running on Mac 10.14.6 and all the solutions I've tried so far have not worked.我在 Mac 10.14.6 上运行,到目前为止我尝试过的所有解决方案都没有奏效。 I am following the docs for OpenAI spinningup and am stuck on this line:我正在关注OpenAI spinup的文档并被困在这条线上:

python -m spinup.run plot data/installtest/installtest_s0

While trying to import matplotlib and plot some graphs however I keep getting:在尝试导入 matplotlib 和 plot 一些图表时,我不断得到:

File /anaconda3/envs/spinningup2/lib/python3.6/site-packages/matplotlib/backends/backend_macosx.py", line 14, in from matplotlib.backends import _macosx ImportError: 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.文件 /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”。

Upon some searching online I see that this is quite a common problem so here is what I have tried so far:在网上搜索后,我发现这是一个很常见的问题,所以这是我迄今为止尝试过的:


1. https://github.com/scikit-optimize/scikit-optimize/issues/637 1. https://github.com/scikit-optimize/scikit-optimize/issues/637

Added添加

import matplotlib
matplotlib.use('PS')

before importing matplotlib.pyplot在导入matplotlib.pyplot之前

I still have the same error.我仍然有同样的错误。


2. https://markhneedham.com/blog/2018/05/04/python-runtime-error-osx-matplotlib-not-installed-as-framework-mac/ 2. https://markhneedham.com/blog/2018/05/04/python-runtime-error-osx-matplotlib-not-installed-as-framework-mac/

Instead of from matplotlib import pyplot as plt I used:而不是from matplotlib import pyplot as plt我使用了:

import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt

However I still get the same error.但是我仍然遇到同样的错误。


3. matplotlib: RuntimeError: Python is not installed as a framework 3. matplotlib: RuntimeError: Python 没有作为框架安装

Add a line:添加一行:

backend: TkAgg

in file:在文件中:

~/.matplotlib/matplotlibrc

This does not solve my issue and I have the same error这不能解决我的问题,我有同样的错误


4. 4.

I try to create a file at ~/.matplotlib/matplotlibrc and populating it with the following text:我尝试在 ~/.matplotlib/matplotlibrc 创建一个文件并使用以下文本填充它:

$ cat ~/.matplotlib/matplotlibrc
backend: TkAgg

When using the cat command, this somehow crashes my MAC and causes a restart.使用cat命令时,这会以某种方式使我的 MAC 崩溃并导致重新启动。 I am very confused.我很困扰。


Any help or suggestions would be greatly appreciated.任何帮助或建议将不胜感激。 I've tried all suggestions I have found on this site with no luck.我已经尝试了我在这个网站上找到的所有建议,但没有运气。

I was able to resolve the issue by uninstalling matplotlib, then reinstalling the exact version I needed (happens to be 3.0.3) using Conda.我能够通过卸载 matplotlib 来解决这个问题,然后使用 Conda 重新安装我需要的确切版本(可能是 3.0.3)。

I also note that Conda installed six (six-1.15.0-py37hecd8cb5_0) as part of this, so not sure what the culprit was but it is fixed now.我还注意到,Conda 安装了六个 (six-1.15.0-py37hecd8cb5_0) 作为其中的一部分,所以不确定罪魁祸首是什么,但现在已修复。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM