Installing MySQL-python with custom mysql installation


Posted:   |   More posts about python mysql sysadmin tip

If you are tryng to:

# pip install MySQL-python

in a system where MySQL is installed manually (not with a packet manager) maybe you'll get into my same troubles.

I've got this error:

Downloading/unpacking MySQL-python
Downloading MySQL-python-1.2.3.tar.gz (70Kb): 70Kb downloaded
Running setup.py egg_info for package MySQL-python
sh: mysql_config: not found
Traceback (most recent call last):
File "", line 14, in
File "/xxx/build/MySQL-python/setup.py", line 15, in
metadata, options = get_config()
File "setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "setup_posix.py", line 24, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
Complete output from command python setup.py egg_info:
sh: mysql_config: not found

Traceback (most recent call last):

File "", line 14, in

File "/xxx/build/MySQL-python/setup.py", line 15, in

metadata, options = get_config()

File "setup_posix.py", line 43, in get_config

libs = mysql_config("libs_r")

File "setup_posix.py", line 24, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

This means that mysql_config is not found into $PATH. We have to rebuild MySQL-python modifing site.cfg like these:

static=True
mysql_config=/path/to/custom/mysql/bin/mysql_config

than update $LD_LIBRARY_PATH with the path to your mysql' lib dir:

# export LD_LIBRARY_PATH=/your/mysql/lib:$LD_LIBRARY_PATH

cross your fingers and then:

# python setup.py install