"無法安裝mysql-python,出現錯誤:找不到mysql_config"
P粉818306280
P粉818306280 2023-08-21 13:30:26
0
2
608
<p><strong>这是我遇到的错误</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 正在运行 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 执行失败,错误代码为 1 完整日志保存在 /home/zjm1126/.pip/pip.log (mysite)zjm1126@zjm1126-G41MT-S2:~/zjm_test/mysite$ pip install mysql-python 正在下载/解压 mysql-python 正在运行 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 执行失败,错误代码为 1 完整日志保存在 /home/zjm1126/.pip/pip.log</pre> <p>我该怎么解决这个问题?</p>
P粉818306280
P粉818306280

全部回覆(2)
P粉156415696

在Mac OS中,我只需在終端機中執行以下命令來修復:

export PATH=$PATH:/usr/local/mysql/bin

這是我找到的最快的解決方法- 它將其添加到路徑中,但如果您計劃在另一個環境中安裝MySQL-python,我認為最好將其永久添加(即將其添加到/etc/paths)。

(在OSX Mountain Lion中測試通過)

P粉024986150

看起來你的系統上缺少mysql_config,或是安裝程式找不到它。 請確保mysql_config確實已安裝。

例如,在Debian/Ubuntu上,你需要安裝以下軟體包:

sudo apt-get install libmysqlclient-dev

也許mysql_config不在你的路徑中,當你自己編譯mysql套件時會出現這種情況。

更新:對於最新版本的Debian/Ubuntu(截至2018年),請使用以下命令:

sudo apt install default-libmysqlclient-dev
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板