MySQL-Python Installation notes, mysql-python notes

Source: Internet
Author: User

MySQL-Python Installation notes, mysql-python notes

After installing mysql-python, the import module prompts the following error,

Copy codeThe Code is as follows:
ImportError: cannot open shared object file: No such file or directory

So google summarized the solution:

(1) locate site. cfg in the installation directory of mysql-ython

#mysql_config = XXXXXXXXXXXXXXXX

Remove the annotation and enter the mysql_config address.

(2) Soft link all the so files about libmysqlclient under mysql/lib to/usr/lib.

ln -s /usr/local/mysql/lib/mysql/libmysqlclient* /usr/libldconfig

In this way

import _mysql

No errors will occur.

Problems with installing mysql-python on ubuntu

Python 2.6

Install MySQL-python using easy_install

Easy_install "MySQL-python = 1.2.3"
Tip: error: Setup script exited with error: command 'gcc 'failed with exit status 1

Python-devel needs to be installed
Sudo apt-get install python-dev
# Apt-get install python-devel
Use easy_install to install the SDK.

If python setup. py is used for installation, the system prompts that mysql_config cannot be found.
EnvironmentError: mysql_config not found
You need to install the following two Development Kits. Note that apt-get does not exist. I will install the SDK using the xinlide Software Package Manager.


After the installation is complete, you need to modify row 26th in under the MySQL-python-1.2.3 folder,

Change mysql_config.path = "mysql_config" to the path of mysql_config.

Whereis mysql_config search path

Mysql_config.path = "/usr/bin/mysql_config"

Python setup. py build
Python setup. py install
You can

Ubuntu root permission

Install MySQL-python

When MySQL-python is installed on centos today, an error is returned. The error message is as follows:

 Running command /home/yunpeng.jiangyp/sys/python/bin/python -c "import setuptools;__file__='/home/admin/jyp/build/MySQL-python/';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-MH5Aya-record/install-record.txt running install running build running build_py copying MySQLdb/ -> build/lib.linux-x86_64-2.7/MySQLdb running build_ext building '_mysql' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/yunpeng.jiangyp/sys/python/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv _mysql.c:44:23: error: my_config.h: No such file or directory _mysql.c:46:19: error: mysql.h: No such file or directory _mysql.c:47:26: error: mysqld_error.h: No such file or directory _mysql.c:48:20: error: errmsg.h: No such file or directory _mysql.c:88: error: expected specifier-qualifier-list before ‘MYSQL' _mysql.c:102: error: expected specifier-qualifier-list before ‘MYSQL_RES'

Google find the answer (, you need to install the mysql-devel.x86_64 first, through

Sudo yum install mysql-devel.x86_64

Re-installation successful

[yunpeng.jiangyp@v010105 ~]$ pip install MySQL-pythonDownloading/unpacking MySQL-python Running egg_info for package MySQL-python Installing collected packages: MySQL-python Running install for MySQL-python building '_mysql' extension gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Dversion_info=(1,2,5,'final',1) -D__version__=1.2.5 -I/usr/include/mysql -I/home/yunpeng.jiangyp/sys/python/include/python2.7 -c _mysql.c -o build/temp.linux-x86_64-2.7/_mysql.o -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -fno-strict-aliasing -fwrapv gcc -pthread -shared build/temp.linux-x86_64-2.7/_mysql.o -L/usr/lib64/mysql -L/usr/lib64 -lmysqlclient_r -lz -lpthread -lcrypt -lnsl -lm -lpthread -lssl -lcrypto -o build/lib.linux-x86_64-2.7/ Successfully installed MySQL-pythonCleaning up...

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.