Python 报错:Library not loaded: li

2020-01-19  本文已影响0人  捞小虾

问题描述


➜  ~ pip3 install mysql-connector-python
➜  ~ pip3 install mysqlclient
➜  ~ python3 -c 'import MySQLdb'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/MySQLdb/__init__.py", line 18, in <module>
    from . import _mysql
ImportError: dlopen(/usr/local/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so, 2): Library not loaded: @rpath/libmysqlclient.21.dylib
  Referenced from: /usr/local/lib/python3.7/site-packages/MySQLdb/_mysql.cpython-37m-darwin.so
  Reason: image not found

问题解决


➜  lib git:(master) ✗ pwd
/usr/local/mysql/lib
➜  lib git:(master) ✗ ls
libcrypto.1.1.dylib          libmysqlclient.dylib         libprotobuf.3.6.1.dylib      mecab
libcrypto.dylib              libmysqlservices.a           libprotobuf.dylib            pkgconfig
libmysqlclient.21.dylib      libprotobuf-lite.3.6.1.dylib libssl.1.1.dylib             plugin
libmysqlclient.a             libprotobuf-lite.dylib       libssl.dylib
➜  sudo ln -s /usr/local/mysql/lib/libmysqlclient.21.dylib /usr/lib/libmysqlclient.21.dylib 
Password:
➜  sudo ln -s /usr/local/mysql/lib/libssl.1.1.dylib /usr/lib/libssl.1.1.dylib
➜  sudo ln -s /usr/local/mysql/lib/libcrypto.1.1.dylib /usr/lib/libcrypto.1.1.dylib
➜  ~ python3 -c "import MySQLdb"                                                     
➜  ~
上一篇下一篇

猜你喜欢

热点阅读