Python 模块安装错误

1.MySQLdb

错误信息:

bogon:desktop LeouWang$ python
Python 2.7.10 (default, Jul 30 2016, 18:31:42) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import MySQLdb
Traceback (most recent call last):
  File "", line 1, in 
  File "/Library/Python/2.7/site-packages/MySQLdb/__init__.py", line 19, in 
    import _mysql
ImportError: dlopen(/Library/Python/2.7/site-packages/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib
  Referenced from: /Library/Python/2.7/site-packages/_mysql.so
  Reason: unsafe use of relative rpath libmysqlclient.18.dylib in /Library/Python/2.7/site-packages/_mysql.so with restricted binary

解决方法:

执行命令:
sudo install_name_tool -change libmysqlclient.18.dylib \ /usr/local/mysql/lib/libmysqlclient.18.dylib \ /Library/Python/2.7/site-packages/_mysql.so

查找网址:http://stackoverflow.com/questions/31343299/mysql-improperly-configured-reason-unsafe-use-of-relative-path

你可能感兴趣的:(Python 模块安装错误)