环境错误:找不到mysql_config

6

环境错误:安装MySQL-python时找不到mysql_config

请问有人能告诉我该怎么做吗?我已经尝试了以下方法:

使用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
2个回答

6

总结其他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

可能解决方法:

环境错误:找不到mysql_config

类似问题:


0

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接