欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

报错:libmysqlclient.so.18: cannot open shared object file: No such file or directory.

程序员文章站 2022-07-15 16:49:26
...

用pycharm连接MySQL数据库时,报错如下:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: libmysqlclient.so.18: cannot open shared object file: No such file or directory. Did you install mysqlclient or MySQL-python?
在网上查找了资料,大部分都是建立软链接,但我搜索了一下没有/usr/local/mysql这个目录,也没有libmysqlclient.so.18这个文件。
解决办法:

sudo pip uninstall MySQL-python       (uninstall from your package manager of choice)
sudo apt-get install libmysqlclient-dev
sudo pip install MySQL-python

现在已经可以正常import MySQLdb

参考链接:
https://*.com/questions/34348752/error-loading-mysqldb-module-libmysqlclient-so-20-cannot-open-shared-object-fi