ImportError: No module named MySQLdb
写的python程序需要与mysql进行交互,在对数据进行查询时,报了以下错误: ImportError: No module named MySQLdb
原因是没有安装第三方模块,python的包中没有自带数据库模块,运行以下命令即可正确安装:
Ubuntu系统: apt-get install python-mysqldb
Centos系统: yum install MySQL-python
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb.
Did you install mysqlclient or MySQL-python?
sudo pip install mysqlclient
sudo yum -y install mysql-devel
sudo yum -y install MySQL-python
sudo pip install MySQL-python