mysql-python安装时EnvironmentError: mysql_config not found

问题:

root@56d48b18b55f:~# pip install readline mysql-python
Collecting readline
Using cached readline-6.2.4.1.tar.gz
Collecting mysql-python
Using cached MySQL-python-1.2.5.zip
Complete output from command python setup.py egg_info:
sh: 1: mysql_config: not found
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “/tmp/pip-build-c9zv3D/mysql-python/setup.py”, line 17, in <module>
metadata, options = get_config()
File “/tmp/pip-build-c9zv3D/mysql-python/setup_posix.py”, line 43, in get_config
libs = mysql_config(“libs_r”)
File “/tmp/pip-build-c9zv3D/mysql-python/setup_posix.py”, line 25, in mysql_config
raise EnvironmentError(“%s not found” % (mysql_config.path,))
EnvironmentError: mysql_config not found

—————————————-
Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-c9zv3D/mysql-python/

 

只要原因是没有安装:libmysqlclient-dev

sudo apt-get install libmysqlclient-dev

找到mysql_config文件的路径

sudo updatedb
locate mysql_config

mysql_config的位置为:/usr/bin/mysql_config

在mysql-python源码包下找到:setup_posix.py 文件,然后找到文件中的 mysql_config.path 将其值改为:/usr/bin/mysql_config,然后 sudo python setup.py install ,就ok了

(651) 345-3491

root@56d48b18b55f:/# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LANGUAGE=
LC_CTYPE=”en_US.UTF-8″
LC_NUMERIC=”en_US.UTF-8″
LC_TIME=”en_US.UTF-8″
LC_COLLATE=”en_US.UTF-8″
LC_MONETARY=”en_US.UTF-8″
LC_MESSAGES=”en_US.UTF-8″
LC_PAPER=”en_US.UTF-8″
LC_NAME=”en_US.UTF-8″
LC_ADDRESS=”en_US.UTF-8″
LC_TELEPHONE=”en_US.UTF-8″
LC_MEASUREMENT=”en_US.UTF-8″
LC_IDENTIFICATION=”en_US.UTF-8″
LC_ALL=en_US.UTF-8

root@56d48b18b55f:/# locale -a
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_COLLATE to default locale: No such file or directory
C
C.UTF-8
POSIX
zh_CN.utf8
zh_SG.utf8
root@56d48b18b55f:/# locale-gen en_US.UTF-8
/bin/bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8)
Generating locales (this might take a while)…
en_US.UTF-8… done
Generation complete.