"Problem included" Importerror No module named MYSQLDB problem solving

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.