"无法安装mysql-python,出现错误:找不到mysql_config"
P粉818306280
P粉818306280 2023-08-21 13:30:26
0
2
533

这是我遇到的错误

(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 "", line 14, in  File "/home/zjm1126/zjm_test/mysite/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 未找到 完整输出如下: sh: mysql_config: 未找到命令 Traceback (most recent call last): File "", line 14, in  File "/home/zjm1126/zjm_test/mysite/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 未找到 ---------------------------------------- 命令 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 "", line 14, in  File "/home/zjm1126/zjm_test/mysite/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 未找到 完整输出如下: sh: mysql_config: 未找到命令 Traceback (most recent call last): File "", line 14, in  File "/home/zjm1126/zjm_test/mysite/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 未找到 ---------------------------------------- 命令 python setup.py egg_info 执行失败,错误代码为 1 完整日志保存在 /home/zjm1126/.pip/pip.log

我该怎么解决这个问题?

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
      最新下载
      更多>
      网站特效
      网站源码
      网站素材
      前端模板
      关于我们 免责声明 Sitemap
      PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!