mac下解决python访问mysql的组件mysql-python异常的bug

问题:

mac系统为10.9,安装mysql server,python为2.7,在访问mysql时,报:Traceback (most recent call last):

File "tests/test_MySQLdb_capabilities.py", line 4, in <module>
import MySQLdb
File "/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/MySQLdb/init.py", line 19, in <module>
import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so, 2): no suitable image found. Did find:
/Library/Python/2.7/site-packages/MySQL_python-1.2.4b4-py2.7-macosx-10.8-intel.egg/_mysql.so: mach-o, but wrong architecture

过程:file`whichpython`

$ file `which mysql` # or mysql_config
$ file /Library/Python/2.7/site-packages/_mysql.so

解决办法:

1. uninstall MySQL and mysql-python
2. reinstall MySQL 64-bit
3. reinstall mysql-python
(at this point, the django syncdb command was failing due to a missing library, libmysqlclient.18.dylib)
4. added environment variable DYLD_LIBRARY_PATH=/usr/local/mysql...../lib, to point to the directory containing the missing dylib

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值