您的位置:首页 > 数据库 > MySQL

使用mysql报错显示Reason: im…

2016-11-15 09:25 351 查看


报错信息:

[code]Traceback (most recent call last):
File “/Volumes/此处省略路径信息.../test.py", line 2, in
import MySQLdb as mdb
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/MySQLdb/__init__.py", line 19, in
import _mysql
ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
Referenced from: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/_mysql.so
Reason: image not found

[/code]
1

2

3

4

5

6

7

8

1

2

3

4

5

6

7

8


报错原因:

找不到libmysqlclient.18.dylib这个文件,但这个文件在/usr/local/MySQL/lib/下是有的,
只是位置不对,于是我们这样解决.


执行命令:

[code]sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

[/code]
1

1


结果提示:

[code]ln: /usr/lib/libmysqlclient.18.dylib: Operation not permitted

[/code]
1

1


原因:

The computer security settings prevent the shared library _mysql.so
from using a relative reference to the library
libmysqlclient.18.dylib. In the future, the shared library
_mysql.so may be updated. Until then, you can force it to use an
absolute reference via the install_name_toolutility. Assuming that
libmysqlclient.18.dylib is in /usr/local/mysql/lib/, then run the
command


解决办法:

输入如下

sudo install_name_tool -change
libmysqlclient.18.dylib
/usr/local/mysql/lib/libmysqlclient.18.dylib
/Users/Victoria/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/MySQL_python-1.2.5-py2.7-macosx-10.6-x86_64.egg/_mysql.so
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: