尝试在Ubuntu / Linux Box上安装MySQL-python时出现以下故障,下面是问题所在,sh: mysql_config: not found 有人可以建议我怎么做吗?
sh: mysql_config: not found
rmicro@ubuntu:~$ pip install MySQL-python 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 "<string>", line 14, in <module> File "/home/rmicro/build/MySQL-python/setup.py", line 15, in <module> 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 "<string>", line 14, in <module> File "/home/rmicro/build/MySQL-python/setup.py", line 15, in <module> 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 ---------------------------------------- Command python setup.py egg_info failed with error code 1
在Ubuntu上,建议使用发行版存储库。因此,安装python-mysqldb应该很简单:
sudo apt-get install python-mysqldb
如果您实际上想使用pip进行安装(如前所述,不是建议的路径,但是可能的话),请查看以下先前提出的问题和答案:pip安装mysql- python失败,出现EnvironmentError:找不到mysql_config
这是开发人员非常全面的指南:http : //mysql-python.blogspot.no/2012/11/is-mysqldb-hard-to- install.html
要获得python-mysqld使用pip安装它的所有先决条件(如果您使用virtualenv,则需要这样做),运行以下命令:
sudo apt-get install build-essential python-dev libmysqlclient-dev