我下载并遵循了MySQL 5.5.8(http://dev.mysql.com/downloads/mysql/)和MySQLdb python插件的安装说明。(http://sourceforge.net/projects/mysql-python/)
当我尝试将MySQLdb导入到python终端时,出现以下错误:
Safira:~ yanigisawa$ python --version Python 2.6.1 Safira:~ yanigisawa$ python -c "import MySQLdb" Traceback (most recent call last): File " ", line 1, in File "build/bdist.macosx-10.6-universal/egg/MySQLdb/ init.py", line 19, in File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.6-universal/egg/_mysql.py", line 6, in bootstrap ImportError: dlopen(/Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.16.dylib Referenced from: /Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so Reason: image not found Safira:~ yanigisawa$ 我在堆栈溢出中发现了问题4559699,并按照那里的指示进行操作:
Safira:~ yanigisawa$ echo $DYLD_LIBRARY_PATH /usr/local/mysql/lib Safira:~ yanigisawa$ ls -l /usr/local/mysql/lib total 363224 -rwxr-xr-x 1 root wheel 3787328 Jan 18 19:41 libmysqlclient.16.dylib -rw-r--r-- 1 root wheel 10035336 Dec 3 13:26 libmysqlclient.a lrwxr-xr-x 1 root wheel 23 Jan 14 22:01 libmysqlclient.dylib -> libmysqlclient.16.dylib lrwxr-xr-x 1 root wheel 20 Jan 14 22:01 libmysqlclient_r.16.dylib -> libmysqlclient.dylib lrwxr-xr-x 1 root wheel 16 Jan 14 22:01 libmysqlclient_r.a -> libmysqlclient.a lrwxr-xr-x 1 root wheel 20 Jan 14 22:01 libmysqlclient_r.dylib -> libmysqlclient.dylib -rw-r--r-- 1 root wheel 88033760 Dec 3 13:22 libmysqld-debug.a -rw-r--r-- 1 root wheel 84075304 Dec 3 13:26 libmysqld.a -rw-r--r-- 1 root wheel 8472 Dec 3 13:26 libmysqlservices.a drwxr-xr-x 13 root wheel 442 Dec 3 13:53 plugin Safira:~ yanigisawa$ md5 /usr/local/mysql/lib/libmysqlclient.16.dylib MD5 (/usr/local/mysql/lib/libmysqlclient.16.dylib) = b8a78a93183720021b9dbe9ddad57111 Safira:~ yanigisawa$ 在清理了所有的python egg文件并重建之后,我仍然遇到相同的错误。然后我在MySQL 5.5.8中发现了影响Mac 10.6的bug 59006(http://bugs.mysql.com/bug.php?id=59006)。我尝试了此处列出的解决方法,清理了鸡蛋并重新构建,但仍然出现此错误。
对于此特定于python的问题,还有另一种解决方法吗?我还有其他东西吗?
编辑:从otool命令添加输出:
Safira:~ yanigisawa$ otool -L /Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so /Users/yanigisawa/.python-eggs/MySQL_python-1.2.3-py2.6-macosx-10.6-universal.egg-tmp/_mysql.so: libmysqlclient.16.dylib (compatibility version 16.0.0, current version 16.0.0) /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 125.2.1) Safira:~ yanigisawa$ otool -DX /usr/local/mysql/lib/libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib Safira:~ yanigisawa$
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。