Python MYSQLDB Linux Installation Notes

Source: Internet
Author: User
Tags stdin

This article mainly introduces the Python mysqldb Linux installation notes, this article explains the rapid installation and manual compilation of installation two methods, and explained the operation steps, the need for friends can refer to the

At home in the Windows environment to get a

See Python mysqldb Fast installation, problem resolution in Windows environment


In the development of the company needs, one more, Linux under.

found that the installation of a compilation is really very painful, but also see the situation, all kinds of problems ... Struggle

There are two ways to do this:

A. Rapid Installation

B. Compile Yourself

1. The quickest and easiest way (in a hurry)

The code is as follows:

sudo yum install Mysql-python

Problems may be encountered:

The code is as follows:

>>> Import MySQLdb

Traceback (most recent call last):

File " ", line 1, in?

File "mysqldb/", line, in?

Raise Importerror ("This are MySQLdb version%s, but _mysql is version%r"%

Importerror:this is MySQLdb version (1, 2, 3, ' final ", 0), but _mysql is version (1, 2, 1, ' final ', 1)

Reason: Before using the compiled method to install, under the 1.2.3, but with Yum current highest 1.2.1, conflict

Workaround: Delete the files that have been compiled

The code is as follows:

RM-RF mysql-python-1.2.3/

Go on

The code is as follows:

>>> Import MySQLdb

Without errors, it means success.

2. Compile and install yourself (if you have time ...) 囧




The code is as follows:

Wget-o setuptools-0.6c8.tar.gz

Extract execution sudo [or python build && sudo python install]

C.python-dev in sudo apt-get install Python-dev

Otherwise the exception will be reported: Fatal error:python.h: No file or directory


A. Download: wget


The code is as follows:

$ tar xfz mysql-python-1.2.3.tar.gz

$ CD mysql-python-1.2.3

$whereis Mysql_config


$ vim Site.cfg

Modify the Mysql_config path for the MySQL configuration file/usr/bin/mysql_config

Also want to modify

The code is as follows:

Threadsafe = False

$ python Build

$ sudo python install

End ~

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.