在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
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正常执行。

STO答案地址:http://stackoverflow.com/questions/21784641/installation-issue-with-matplotlib-python

RuntimeError: Python is not installed as a framework 错误解决方案的更多相关文章

  1. RuntimeError: Python is not installed as a framework 错误解决办法

    因为我是macbook,mac是自带的python 2.7,但是我开发需要使用到的是python3,所以先使用pip3 install matplotlib 然后在交互页面键入import matpl ...

  2. matplotlib使用时报错RuntimeError: Python is not installed as a framework(一)

    笔者在第一次安装matplotlib后运行时出现报错. import matplotlib as mlb from matplotlib import pylab as pl x = [1,3,5,7 ...

  3. RuntimeError: Python is not installed as a framework.

    RuntimeError: Python is not installed as a framework. 文章转载:https://www.cnblogs.com/harelion/p/563776 ...

  4. 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

    在virtualenv环境下使用matplotlib绘图时遇到了这样的问题: >>> import matplotlib.pyplot as pltTraceback (most r ...

  5. 出现ImportError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly ....的解决方法

    在terminal上运行gluoncv时遇到了一个报错问题. ImportError: Python is not installed as a framework. The Mac OS X bac ...

  6. pip install报错:RuntimeError: Python version >= 3.5 required

    由于pip官方的不作为,现如今python2(以及某些低版本python3)配套的pip,已经没法正常的安装pypi包了. 例如需要用到的一套PyCaffe的代码,是基于Python2的,于是用min ...

  7. plugin python was not installed: Cannot download ''

    problem: plugin python was not installed: Cannot download ''........ 1. the first method of resoluti ...

  8. python学习笔记系列----(六)错误和异常

    python至少有2类不同的错误:语法错误(Syntax Errors)和异常(Exceptions). 8.1 语法错误 这个单词应该还是很有必要认识的,呵呵,语法错误,也叫解析错误,是我们最不愿意 ...

  9. Python运行Google App Engineer时出现的UnicodeDecodeError错误解决方案

    #Python运行Google App Engineer时出现的UnicodeDecodeError错误解决方案   ##问题描述 使用Python2.7.x运行GAE时有时会报这个错误 ```py ...

随机推荐

  1. [20180705]关于hash join 2.txt

    [20180705]关于hash join 2.txt --//昨天优化sql语句,执行计划hash join right sna,加入一个约束设置XX字段not null,逻辑读从上万下降到50.- ...

  2. < meta http-equiv = "X-UA-Compatible" content = "IE=edge,chrome=1" />的意义

    X-UA-Compatible是神马? X-UA-Compatible是IE8的一个专有<meta>属性,它告诉IE8采用何种IE版本去渲染网页,在html的<head>标签中 ...

  3. Mac上用spotlight搜索输入几个字母后闪退

    最近使用电脑时遇到的问题: 使用spotlight进行搜索时,只要输入字母超过一定个数(在我的Mac上是3个),spotlight就闪退了. 谷歌搜索得到大部分解决方案是在系统自带词典的偏好设置里取消 ...

  4. selenium+Python3.5获取验证码

    其中PIL为Python Imaging Library,已经是Python平台事实上的图像处理标准库了.PIL功能非常强大,但API却非常简单易用. PIL第三方库安装 pip install PI ...

  5. EBS-新增和更新价目表行

    版权声明:本文为博主原创文章.未经博主同意不得转载. https://blog.csdn.net/gh320/article/details/36666133  新增和更新价目表行 --目的:在已 ...

  6. redsi一主两从三哨兵

    1.前提准备 防火墙,selinux,主机名解析,所有主机安装gcc [root@localhost ~]# vim /etc/hosts 192.168.122.135  redis_master ...

  7. 遇到的web请求错误码集合与解释

    302 临时移动.与301类似.但资源只是临时被移动.客户端应继续使用原有URI

  8. 使用Mongoose类库实现简单的增删改查

    使用Mongoose类库实现简单的增删改查 Mongoose是在nodejs环境中对MongoDB数据库操作的封装,一种对象模型工具,可以将数据库中的数据转换为javascript对象供我们使用. M ...

  9. stm32 中断号和中断处理函数建立关系

    转载:https://www.cnblogs.com/heny-hui/p/7130620.html stm32的中断号根据不同内核和型号,st公司给的官方库中对相应的中断号进行了设置,我们用到哪一个 ...

  10. 【Codeforces 1114F】Please, another Queries on Array?

    Codeforces 1114 F 题意:给你一个序列\(a_{1\dots n}\),以及\(q\)次查询,每次查询有两种格式: TOTIENT \(l\) \(r\):求出\(\phi(\Pi_{ ...