问题:
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
本文解决了一个在MacOS 10.9环境下使用Python 2.7访问MySQL时遇到的错误:缺少libmysqlclient.18.dylib动态库。通过卸载并重新安装MySQL和mysql-python模块,调整环境变量DYLD_LIBRARY_PATH,最终成功解决了问题。
1269

被折叠的 条评论
为什么被折叠?



