开发者社区> 问答> 正文

Python导入MySQLdb错误-Mac 10.6?mysql

我下载并遵循了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$

展开
收起
保持可爱mmm 2020-05-17 19:36:06 32366 0
1 条回答
写回答
取消 提交回答
  • 检查您的apache错误日志中是否有错误。另外,尝试使用_www并手动执行脚本。来源:stack overflow

    2020-05-18 13:40:17
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
From Python Scikit-Learn to Sc 立即下载
Data Pre-Processing in Python: 立即下载
双剑合璧-Python和大数据计算平台的结合 立即下载