Python Module Mysql-python installation (under Ubuntu System)

Source: Internet
Author: User

Run the following command directly

sudo pip install Mysql-python

Report the following error

[Email protected]:~$ sudo pip install mysql-pythondownloading/unpacking mysql-python downloading MySQL-python-1.2.5. zip (108kB): 108kB downloaded Running (path:/tmp/pip_build_root/mysql-python/ Egg_info forPackage mysql-python sh:1:mysql_config: notfound Traceback (most recent): File"<string>", line 17,inch<module>File"/tmp/pip_build_root/mysql-python/", line 17,inch<module>metadata, Options=get_config () File"", line 43,inchGet_config Libs= Mysql_config ("Libs_r") File"", line 25,inchMysql_configRaiseEnvironmentError ("%s not found"%(Mysql_config.path,)) Environmenterror:mysql_config notfound complete output fromcommand python egg_info:sh:1:mysql_config: notFound

Solutions are:

Installing Python-dev
sudo apt-get install Python-dev

And then install

sudo apt-get install Libmysqlclient-dev

Final installation

sudo pip install Mysql-python

This will be a success.

Here is the test code:

ImportMySQLdbTry: Conn= MySQLdb.connect (host='', user='Root', passwd='Root', db='MyDB', port=3306) cur=conn.cursor () Cur.execute ('INSERT into test values (0, "x0")') Conn.commit () Cur.close () Conn.close ( )Print "Finish Insert Direct"exceptmysqldb.error,e:PrintE.ARGS[1]

Python Module Mysql-python installation (under Ubuntu System)

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: 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.