Linux under compilation installation Mysql-python tutorial

Source: Internet
Author: User
1. Download Mysql-python

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

2, Installation Mysql-python
Copy the 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 requires MySQL header file.
2. Installing Mysql-python requires setuptools tools.

3. Testing
Copy the Code code as follows:


# python
>>> Import MySQLdb
>>>


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

Error message:
Copy the 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


Cause of Error:

Executing the python setup.py install,mysqldb module will be copied to the Python site-packages directory. If the same module exists in the directory where Python is executed, the module may be imported repeatedly.

Workaround:

You can do python in a different directory.

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