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 infor,,在virtualen
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 infor,,在virtualen
在virtualenv环境下使用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
似乎是因为虚拟环境与默认环境的安装配置不同造成的。
搜索错误信息之后,在STO上找到了解决方案:
1、pip安装matplotlib之后,会在根目录下产生一个.matplotlib的目录:
? bin ll ~/.matplotlib
我是通过cd ~/.matplotlib 进入这个文件夹的 cd ~命令是进入home目录 (就是进入home目录下的一个.matplotlib文件夹下)
total 280
-rw-r--r-- 1 me staff 78K 10 4 2015 fontList.cache
-rw-r--r-- 1 me staff 59K 1 17 15:56 fontList.py3k.cache
drwxr-xr-x 2 me staff 68B 10 4 2015 tex.cache
2、在这个目录下创建一个名为matplotlibrc的文件,内容是:
backend: TkAgg
然后保存退出,重启Python交互界面或重新运行脚本,import正常执行。
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 infor
相关内容
- java如何实现python的urllib.quote(str,safe='/'),
- Python3之urllib模块,python3urllib,简介 urllib
- Python3 引入sqlite3时出现错误:ModuleNotFoundError: No module
- Python学习笔记整理总结【ORM(SQLAlchemy)】,ormsqlalche
- 如何用python爬取两个span之间的内容,pythonspan,Python用做
- python之单元测试框架—unittest(补充),pythonunittest,一.
- python第一章练习题,python第一章,本章总节练习题1.简
- linux和windows下安装python拓展包及requirement.txt安装类库,
- 学习 python 编写规范 pep8 的问题笔记,pythonpep8,决定开始
- python函数的4个你可能不知道的事,python函数, 关于
评论关闭