码迷,mamicode.com
首页 > 数据库 > 详细

MAC OSX使用Python安装mysql模块问题

时间:2015-01-26 19:01:54      阅读:266      评论:0      收藏:0      [点我收藏+]

标签:

系统环境:MAC OSX 10.9.2
Python版本:2.7.5
新入手的RMBP,自带了Python环境,但是将其投入到生产环境时,出现了种种问题,首先最最致命的,就是安装模块出现问题,导致一直无法正常开发,下面是本人在安装Python模块的时候,所出现并解决的,总结如下,希望对后来者有帮助(拿MySQL-python举例,安装PIL也遇到了同样的问题):
(1)不管在使用easy_install安装模块,还是下载安装包,使用sudo python setup.py build安装,都会出现:
******
error: command ‘cc‘ failed with exit status 1
clang: error: unknown argument: ‘-mno-fused-madd‘ [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command ‘cc‘ failed with exit status 1
经过一系列的查找:http://www.tuicool.com/articles/zI7Vzu,貌似是MAC OS的Xcode从5.1起给编译器规定对于未知参数传入视为error,我们需要使用ARCHFLAGS将该error降级为warning,因此最后的安装命令应该如下:
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future easy_install MySQL-python
这样,问题就解决了,成功安装上了MySQL-python
(2)虽然安装上了MySQL-python,在代码开发过程中,运行代码,问题又出现了:
******
import MySQLdb
File "build/bdist.macosx-10.9-intel/egg/MySQLdb/__init__.py", line 19, in <module>
File "build/bdist.macosx-10.9-intel/egg/_mysql.py", line 7, in <module>
File "build/bdist.macosx-10.9-intel/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/kris/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.9-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Users/kris/.python-eggs/MySQL_python-1.2.5-py2.7-macosx-10.9-intel.egg-tmp/_mysql.so
Reason: image not found
经过查找,我添加两个符号链接(软链接):
sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
再次运行程序,问题就解决了。

MAC OSX使用Python安装mysql模块问题

标签:

原文地址:http://www.cnblogs.com/kingdong/p/4250782.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!