Mac 使用virtualenv安装 matplotlib的解决方案

来源:互联网 发布:私募公募 知乎 编辑:程序博客网 时间:2024/05/29 12:49

Mac上安装matplotlib的时候除了增加和配置~/.matplotlib/matplotlibrc

如果在virtualenv下安装还会有:RuntimeError: Python is not installed as a framework. The Mac OS X backend的错误

在你的 ~/.bash_profile文件中加上这一句:

export PYTHONHOME="/Users/yourUserName/.virtualenvs/yourEnvName" # 两个地方自己替换一下

然后直接启动python就可以了,
连virtualenv也不用切换了,
直接全部使用你虚拟环境的库,
matplotlib.pyplot也可以使用,

只是如果你要换环境,就得去改bash_profile

另外,如果virtualenv用的是3.0+,默认启动2.7就会出错,
启动virtualenv所使用的那个3.0+的python就好了

原创粉丝点击