Anaconda 运行时错误:Python 未作为框架安装?

2022-01-10 00:00:00 python matplotlib macos anaconda

问题描述

我已经使用 pkg 安装程序安装了 Anaconda:

I've installed Anaconda with the pkg installer:

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

但是当我尝试使用 matplotlib 中的任何东西时,即:

but when I attempt to use anything from matplotlib, i.e.:

 from matplotlib import pyplot as plt

我明白了

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.


解决方案

如果您遇到此错误,请不要忘记检查您的 bash_profile.

If you experience this error, don't forget to check your bash_profile.

您可以通过以下方式在终端中执行此操作:

You can do this in terminal by:

cd

然后

nano .bash_profile

检查内容.Macports 和 Homebrew 为他们在这里所做的事情添加了自己的标题.您可以删除他们对 $PATH 所做的声明.只留下 Anaconda 制作的那个.我有一个如果你愿意,你可以:

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:

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

将刷新您的系统对 bash_profile 的引用,您应该可以很好地导入和使用 matplotlib

will refresh your system's reference to the bash_profile and you should be good to go in importing and using matplotlib

相关文章