Anaconda 运行时错误:Python 未作为框架安装?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31373163/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Anaconda Runtime Error: Python is not installed as a framework?
提问by Mark Brown
I've installed Anaconda with the pkg installer:
我已经使用 pkg 安装程序安装了 Anaconda:
Python 2.7.10 |Continuum Analytics, Inc.| (default, May 28 2015, 17:04:42)
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://binstar.org
but when I attempt to use anything from matplotlib, i.e.:
但是当我尝试使用 matplotlib 中的任何内容时,即:
from matplotlib import pyplot as plt
I get
我得到
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.
I'm really not sure what this means, or how to go about fixing it.
我真的不确定这意味着什么,或者如何解决它。
采纳答案by Mark Brown
If you experience this error, don't forget to check your bash_profile.
如果您遇到此错误,请不要忘记检查您的 bash_profile。
You can do this in terminal by:
您可以通过以下方式在终端中执行此操作:
cd
then
然后
nano .bash_profile
check the contents. Macports and Homebrew add their own headings for things they've done here. You can remove the declarations they make to $PATH. Just leave the one Anaconda has made. I had a If you would like, you can:
检查内容。Macports 和 Homebrew 为他们在这里所做的事情添加了自己的标题。您可以删除他们对 $PATH 所做的声明。只留下 Anaconda 制作的那个。我有一个如果你愿意,你可以:
cp .bash_profile ./bash_profile_backup_yyyy_mm_dd
and have a backup of the file, with filename indexing to the date you changed it. That is, provided you actually put in the date in instead of just the formatting characters I'm suggesting.
并备份文件,文件名索引到您更改它的日期。也就是说,只要您实际输入日期,而不仅仅是我建议的格式字符。
source ~/.bash_profile
will refresh your system's reference to the bash_profile and you should be good to go in importing and using matplotlib
将刷新您的系统对 bash_profile 的引用,您应该很好地导入和使用 matplotlib
回答by Bobby
if using inside a virtualenv, I recommend following the instructions here: http://matplotlib.org/faq/virtualenv_faq.html
如果在 virtualenv 中使用,我建议按照以下说明操作:http: //matplotlib.org/faq/virtualenv_faq.html
回答by Glenn Cameron
I was having the same problem. Installing an older version of matplotlib did the trick for me. Try this command in your terminal while in your virtual environment:
我遇到了同样的问题。安装旧版本的 matplotlib 对我有用。在虚拟环境中,在终端中尝试此命令:
pip install matplotlib==1.4.3
回答by SeF
If the problem is only matplotlib, is worth try to change the backend:
如果问题只是matplotlib,值得尝试更改后端:
import matplotlib
matplotlib.use('TkAgg')
import matplotlib.pyplot as plt
plt.plot([1, 2, 3], [4, 5, 6])
plt.show()
If it works you can change the backend permanently from the matplotlibrc file.
如果可行,您可以从 matplotlibrc 文件中永久更改后端。
回答by dangom
I was having the same problem with anaconda 2 & matplotlib 1.5.3.
我在使用 anaconda 2 和 matplotlib 1.5.3 时遇到了同样的问题。
Running a simple conda install matplotlib
to reinstall matplotlib did the trick for me.
运行一个简单conda install matplotlib
的重新安装 matplotlib 对我有用。
回答by devssh
Run the file using pythonw
instead of python
.
This happens because python is not installed as a framework.
Therefore use pythonw myScript.py
instead of python myScript.py
I am sure this will fix it.
使用pythonw
而不是运行文件python
。发生这种情况是因为 python 没有作为框架安装。因此使用pythonw myScript.py
而不是python myScript.py
我相信这会解决它。
I had a similar error.
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 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.
我有一个类似的错误。
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 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.
回答by Jared Wilber
Posting since I just had this issue and this was a quick fix:
因为我刚刚遇到这个问题而发帖,这是一个快速解决方案:
If you used pip to install:
如果您使用 pip 安装:
Create
~/.matplotlib/matplotlibrc
Add "
backend: TkAgg
" (without the quotations) to the file.
创建
~/.matplotlib/matplotlibrc
将“
backend: TkAgg
”(不带引号)添加到文件中。
回答by Cory Watts
A reinstall of matplotlib should fix the issue for you as it did for me with
重新安装 matplotlib 应该可以像对我一样为您解决问题
conda install matplotlib
conda 安装 matplotlib
回答by Sehul Viras
Quickfix: Run your file using pythonw, instead of python.
快速修复:使用 pythonw 而不是 python 运行你的文件。
e.g pythonw testFile.py.
例如 pythonw testFile.py。
回答by danodonovan
From the matplotlib documentation;
$ conda install python.app
$ conda install python.app
You need a framwork build of Python for matplotlib, but
你需要一个用于 matplotlib 的 Python 框架构建,但是
The default python provided in (Ana)conda is not a framework build. However, a framework build can easily be installed, both in the main environment and in conda envs: install python.app (conda install python.app) and use pythonw rather than python
(Ana)conda 中提供的默认 python 不是框架构建。但是,可以在主环境和 conda envs 中轻松安装框架构建:安装 python.app (conda install python.app) 并使用 pythonw 而不是 python
NB I had to add the conda-forge
channel as python.app
isn't included in the default miniconda channels
注意,我必须添加conda-forge
通道,因为python.app
默认 miniconda 通道中不包含该通道
$ conda config --add channels conda-forge
$ conda config --add channels conda-forge