Linux to compile and install the Mysql-python tutorial _python

Source: Internet
Author: User

1, download Mysql-python

Website address: http://sourceforge.net/projects/mysql-python/

2. Installation Mysql-python

Copy Code code as follows:

# TAR-ZXVF Mysql-python-1.2.3.tar.gz
# CD mysql-python-1.2.3
# Whereis Mysql_config
Mysql_config:/usr/bin/mysql_config/usr/share/man/man1/mysql_config.1.gz
# VI Site.cfg
Threadsafe = False
Mysql_config =/usr/bin/mysql_config
# Whereis MySQL
MySQL:/usr/bin/mysql/usr/lib/mysql/usr/include/mysql/usr/share/mysql/usr/share/man/man1/mysql.1.gz
# Export Ld_library_path=/usr/include/mysql
# python setup.py Build
# python setup.py Install

Attention:
1. Compile Mysql-python need MySQL header file.
2. Installation of Mysql-python requires Setuptools tools.

3, testing

Copy Code code as follows:

# python
>>> Import MySQLdb
>>>

If there are no error prompts or the following error prompts, the installation is successful.

Error Tip:

Copy Code code as follows:

/usr/local/lib/python2.6/site-packages/mysql_python-1.2.3-py2.6-linux-x86_64.egg/_mysql.py:3: UserWarning: Module _mysql was already imported from/usr/local/lib/python2.6/site-packages/mysql_python-1.2.3-py2.6-linux-x86_ 64.EGG/_MYSQL.PYC, but/root/mysql-python-1.2.3 is being added to Sys.path

The reason for the error:

Executing the python setup.py install,mysqldb module will be copied to the Python site-packages directory. If you have the same module in the directory where Python is executing, you may be able to repeat the import module.

Solution:

You can do python in a different directory.

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.