ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory 解决办法

时间:2022-04-28 11:56:11

>>> import MySQLdb
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/MySQLdb/__init__.py", line 19, in <module>
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 7, in <module>
  File "build/bdist.linux-x86_64/egg/_mysql.py", line 6, in __bootstrap__
ImportError: libmysqlclient.so.20: cannot open shared object file: No such file or directory

解决办法:

到/opt/mysql/lib/ 目录下,找到 libmysqlclient.so.20.1.0 文件,然后做一个软连接:

ln -s /opt/mysql/lib/libmysqlclient.so.20.1.0 /usr/lib64/libmysqlclient.so.20