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

用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://stackoverflow.com/questions/34348752/error-loading-mysqldb-module-libmysqlclient-so-20-cannot-open-shared-object-fi

你可能感兴趣的:(Linux,数据库)