1. See if the MySQLdb module is already installed
Go to the Python command line and enter import MySQLdb. If there is no error, prove that the module has been installed, otherwise we need to do several operations.
2. Install and download mysql for Python
MySQL for Python url is http://sourceforge.net/projects/mysql-python/, can download install the latest version, the command is as follows
<span style= "FONT-SIZE:12PX;" >wget HTTP://SOURCEFORGE.NET/PROJECTS/MYSQL-PYTHON/FILES/LATEST/DOWNLOADTAR-XVZF MYSQL-PYTHON-1.2.4B4.TAR.GZCD mysql-python-1.2.4b4python setup.py Buildpython setup.py install</span>
If you execute the python setup.py build times error Environmenterror:mysql_config not found, you need to do the following:
Using the Whereis mysql_config command, we also need to install something else if the following result is present:
My MySQL is installed under the default path of the system
We're installing dev at this time.
Apt-get Install Libmysqlclient15-dev
Modify the mysql-python-1.2.4b4/site.cfg file, remove the mysql_config=xxx annotation, and change to Mysql_config=/usr/bin/mysql_ Config
Back to the MySQLdb source directory, vi setup_posix.py or vimsetup_posix.py open the configuration file, find the Mysql_config.path line, change the path to the MySQL installation path under the Bin directory, that is Mysql_ Config.path = "/usr/local/mysql/bin/mysql_config"
Execute the following command again
Python setup.py Build
Python setup.py Install
"Problem included" Importerror No module named MYSQLDB problem solving