使用MYSQLDB安装Python 2.7 centos

时间:2017-04-17 19:22:28

标签: python-2.7 mysql-python

以下是我遵循的步骤。我不想打扰已经在服务器上的Pythn2.6,但我想分开安装python 2.7

 1) sudo yum install python27 python27-pip 

2) sudo yum -y install python27-devel libxslt-devel libffi-devel openssl-devel 3) sudo yum install python27-MySQL-python 我在安装MYSQLDB时遇到以下错误

Collecting MySQL-python
  Using cached MySQL-python-1.2.5.zip
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-ixxaPu/MySQL-python/setup.py", line 17, 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

    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ixxaPu/MySQL-python/

请帮我解决或如何调试问题

2 个答案:

答案 0 :(得分:2)

以下内容也应该有效:

sudo yum whatprovides mysql_config

这将列出包含与字符串mysql_config匹配的文件名的包。

然后只需安装一个建议的软件包。

答案 1 :(得分:1)

经过一天的努力,我找到了很多博客说要安装的答案

mysql-devel

但这是安装旧版本的mysql-5.1 现在我们使用percona,所以我尝试搜索percona客户端当前版本

yum list installed | grep -i percona

并安装了相同的Devel版本以下是命令

sudo yum install Percona-Server-devel-56.x86_64

这安装了你可以用

交叉检查的mysql_config
which mysql_config

然后安装

 sudo pip2.7 install MySQL-python

这就是它的所有工作