Python MYSQLDB Linux Installation Notes

Source: Internet
Author: User

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

Http://www.jb51.net/article/65746.htm

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/__init__.py", 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 ...) 囧

Need:

a.gcc

B.setuptools

The code is as follows:

Wget-o setuptools-0.6c8.tar.gz http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c8.tar.gz

Extract execution sudo easy_install.py [or python setup.py build && sudo python setup.py 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

Steps:

A. Download: wget http://sourceforge.net/projects/mysql-python/files/latest/download

B.

The code is as follows:

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

$ CD mysql-python-1.2.3

$whereis Mysql_config

Mysql_config:/usr/bin/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 setup.py Build

$ sudo python setup.py install

End ~

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.