EnvironmentError:找不到mysql_config [重复]

Posted

技术标签:

【中文标题】EnvironmentError:找不到mysql_config [重复]【英文标题】:EnvironmentError: mysql_config not found [duplicate] 【发布时间】:2013-10-24 03:59:09 【问题描述】:

EnvironmentError: mysql_config not found, while installation MySQL-python

有人可以告诉我该怎么做吗?我从我身边做了以下事情:

我在使用 pip 安装时遇到的错误:

  ubuntu12.04@ubuntu12.04:~$ sudo pip install mysql-python
    Downloading/unpacking MySQL-python
    Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
    Running setup.py egg_info for package MySQL-python
    sh: 1: mysql_config: not found
 Traceback (most recent call last):
  File "<string>", line 16, in <module>
  File "/tmp/pip_build_root/MySQL-python/setup.py", line 18, 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 25, 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: 1: mysql_config: not found

Traceback (most recent call last):

 File "<string>", line 16, in <module>

 File "/tmp/pip_build_root/MySQL-python/setup.py", line 18, 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 25, in mysql_config

raise EnvironmentError("%s not found" % (mysql_config.path,))

  EnvironmentError: mysql_config not found

   ----------------------------------------
 Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip_build_roo

我在我的电脑上运行 UBUNTU 12.04 LTS

手动安装会出现同样的错误。我试过easy_install,也没有用。

我手动搜索了mysql_config,在系统文件的任何地方都找不到。

经过快速搜索,我发现 mysql_config 属于 libmysqlclient-dev。所以,我尝试使用以下方法获取这些包:

 sudo apt-get install libmysqlclient-dev

它给出了以下输出:

  Reading package lists... Done
  Building dependency tree       
  Reading state information... Done
  Package libmysqlclient-dev is not available, but is referred to by another package.
  This may mean that the package is missing, has been obsoleted, or
  is only available from another source
  However the following packages replace it:
  mysql-server-5.5

  E: Package 'libmysqlclient-dev' has no installation candidate

我什至从源代码下载了 libmysqlclient-dev 包并尝试手动安装它们,它给出了依赖错误。以下是安装时的输出。

  ubuntu@ubuntu:~/Downloads$ sudo dpkg -i libmysqlclient-dev_5.5.32-            0ubuntu0.12.04.1_amd64.deb 
  Selecting previously unselected package libmysqlclient-dev.
  (Reading database ... 203659 files and directories currently installed.)
   Unpacking libmysqlclient-dev (from libmysqlclient-dev_5.5.32-0ubuntu0.12.04.1_amd64.deb) ...
  dpkg: dependency problems prevent configuration of libmysqlclient-dev:
  libmysqlclient-dev depends on libmysqlclient18 (= 5.5.32-0ubuntu0.12.04.1); however:
  Version of libmysqlclient18 on system is 5.5.33+dfsg-1.
  dpkg: error processing libmysqlclient-dev (--install):
  dependency problems - leaving unconfigured
  Processing triggers for man-db ...
  Errors were encountered while processing:
  libmysqlclient-dev

【问题讨论】:

【参考方案1】:

总结其他SO问题中提供的一些解决方案(并基于错误输出)。首先,

sudo apt-get update

所以它的作用是

用于从源重新同步包索引文件。可用包的索引是从 /etc/apt/sources.list(5) 中指定的位置获取的。

并且可以解决

dpkg:依赖问题阻止了 libmysqlclient-dev 的配置

如果sudo apt-get install libmysqlclient-dev 仍然不起作用,则运行以下命令

sudo apt-get install python-dev

sudo apt-get install python-mysqldb

最后,检查mysql_config是否在你的PATH中;必要时添加

export PATH=$PATH:/path/to/your/mysql_config

可能解决

EnvironmentError: mysql_config not found

类似的:

https://askubuntu.com/questions/252777/how-can-i-resolve-dpkg-dependency https://askubuntu.com/questions/222348/what-does-sudo-apt-get-update-do https://askubuntu.com/questions/292865/upgrade-mysql-server-issue pip install mysql-python fails with EnvironmentError: mysql_config not found virtualenv, mysql-python, pip: anyone know how?

【讨论】:

【参考方案2】:

尝试添加apt-get源码列表,使用apt-get安装,可以防止dpkg报错。

检查这个:https://www.howtoinstall.co/en/ubuntu/trusty/libmariadbclient-dev

【讨论】:

以上是关于EnvironmentError:找不到mysql_config [重复]的主要内容,如果未能解决你的问题,请参考以下文章

ubuntu安装EnvironmentError: mysql_config not found错误

raise EnvironmentError("%s not found" % (mysql_config.path,)) EnvironmentError: mysql_

[已解决]EnvironmentError: mysql_config not found

MySQL-python 未安装在 virtualenv 中(EnvironmentError: mysql_config not found)

mysql-python安装时EnvironmentError: mysql_config not found

centos7 安装 mysql-python时 报错 EnvironmentError: mysql_config not found