zoukankan      html  css  js  c++  java
  • 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 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正常执行。

  • 相关阅读:
    VS2005中Ajax控件作用说明
    DevExpress 2.0 GridControl 使用方法
    主机信息
    sql2005中运用一条sql语句完成数据导出到Excel中
    跟我学做c#皮肤美化
    (转)QT事件传递与事件过滤器
    (转)主成分分析(Principal components analysis)最大方差解释
    这是填充首页的
    (转)C++中extern “C”含义深层探索
    (转)如何配置Qt使用VS2010进行开发
  • 原文地址:https://www.cnblogs.com/AlvinSui/p/8987472.html
Copyright © 2011-2022 走看看