解决python在本机Mac上出错:RuntimeError: Python is not installed as a framework.

一. 问题现象: 

调用库:#import matplotlib.pyplot as plt

弹出错误提示:

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.
二.问题解决

==================================

2014-01-10 (注) 原方案存在问题:在安装cx_Freeze-4.3.2的时候,无法找到需要的库文件.

在Python3.3的源码包里面,有ReadMe文件,里面有段话:

 31 On Mac OS X, if you have configured Python with --enable-framework, you should
 32 use "make frameworkinstall" to do the installation.  Note that this installs the
 33 Python executable in a place that is not normally on your PATH, you may want to
 34 set up a symlink in /usr/local/bin.

所以,解决办法是:

 ./configure --enable-framework
sudo  make frameworkinstall

sudo make install

==================================


(1) 安装python3.3后,按照如下文章内容操作

http://www.chenwg.com/python/%E6%9B%B4%E6%96%B0mac%E8%87%AA%E5%B8%A6%E7%9A%84python.html

或者

http://blog.richieliu.com/

(2) 删除其他目录下的python

(3)过程中曾经尝试:修改配置文件 matplotlibrc. 

locate该文件并拷贝到~/.matplotlib/ 目录下进行编辑.

但本机仍然失败,因为依赖其他文件(库).

因此决定采用(1)(2)中方案,最终成功.


三. 原因分析和资料索引

(1) 本机上有2个python3.3,一个在/opt下,一个在/usr/bin下. 删除/opt下python结果OK.

猜测:每次调用都是跑到/opt下的python,导致出错.

rm -rf /opt/local/Library/Frameworks/Python.framework/

(2) 正确的python运行目录

/System/Library/Frameworks/Python.framework/Versions/3.3/bin/python3

(3) matplot运行(傅里叶变换)所需库文件列表:

Python-3.3.3
FFT-tools
lxml-3.2.4
matplotlib-1.3.1
nose-1.3.0
numpy-1.8.0
pyparsing-2.0.1
python-dateutil-2.1
setuptools-1.4
six-1.4.1
tornado-3.1.1



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值