"Unable to install mysql-python, error: mysql_config not found"
P粉818306280
2023-08-21 13:30:26
<p><strong>這是我遇到的錯(cuò)誤</strong></p>
<pre class="brush:php;toolbar:false;">(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
正在下載/解壓 mysql-python
正在下載 MySQL-python-1.2.3.tar.gz (70Kb): 已下載 70Kb
正在運(yùn)行 setup.py egg_info 用于包 mysql-python
sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/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 未找到
完整輸出如下:
sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/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 未找到
----------------------------------------
命令 python setup.py egg_info 執(zhí)行失敗,錯(cuò)誤代碼為 1
完整日志保存在 /home/zjm1126/.pip/pip.log
(mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python
正在下載/解壓 mysql-python
正在運(yùn)行 setup.py egg_info 用于包 mysql-python
sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/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 未找到
完整輸出如下:
sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 14, in <module>
File "/home/zjm1126/zjm_test/mysite/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 未找到
----------------------------------------
命令 python setup.py egg_info 執(zhí)行失敗,錯(cuò)誤代碼為 1
完整日志保存在 /home/zjm1126/.pip/pip.log</pre>
<p>我該怎么解決這個(gè)問題?</p>
In Mac OS, I simply ran the following command in Terminal to fix:
export PATH=$PATH:/usr/local/mysql/bin
This is the quickest workaround I've found - it adds it to the path, but if you plan to install MySQL-python in another environment, I think it's better to add it permanently (i.e. add it to /etc/paths
).
(Tested in OSX Mountain Lion)
Like +0
P粉818306280
reply
It looks like mysql_config is missing on your system, or the installer can't find it.
Please make sure mysql_config is indeed installed.
For example, on Debian/Ubuntu, you need to install the following packages:
sudo apt-get install libmysqlclient-dev
Maybe mysql_config is not in your path, this will happen when you compile the mysql suite yourself.
UPDATE: For the latest versions of Debian/Ubuntu (as of 2018), use the following commands:
sudo apt install default-libmysqlclient-dev
Like +0
P粉818306280
reply