Centos prompt ImportError: No module named MySQLdb solution

Source: Internet
Author: User
Tags centos

System: centos 5.9
Required software packages: setuptools-0.6c11.tar.gz
MySQL-python-1.2.3.tar.gz
              
1. Install setuptools-0.6c11

The code is as follows: Copy code
Wget -- no-check-certificate http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz
Tar zxf setuptools-0.6c11.tar.gz & cd setuptools-0.6c11
Python setup. py build
Python setup. py install

2. Install MySQL-python-1.2.3

The code is as follows: Copy code
Wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz/download
Tar zxf MySQL-python-1.2.3.tar.gz & cd MySQL-python-1.2.3
Python setup. py build
Python setup. py install

If you are running python setup. in py build, if EnvironmentError: mysql_config not found is reported, first find the location of mysql_config and use find/-name mysql_config. Mine is in/usr/local/mysql/bin/mysql_config, then modify the site under the MySQL-python-1.2.3 directory. in the cfg file, remove the comments of mysql_config = XXX and change them to mysql_config =/usr/local/mysql/bin/mysql_config, which is based on your own machine.

Run the following command.

The code is as follows: Copy code
Python setup. py build
Python setup. py install

Okay, solved the problem of MySQLdb. I want to continue to study the web monitoring system.

Ubuntu system

Direct

Sudo apt-get install python-mysqldb


If you compile

Sudo apt-get install libmysqlclient-dev is required

Related Article

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.