用Python连接MySQL

时间:2015-09-03 11:00:12

标签: python mysql

我试图将mysql与python连接起来。我使用命令" sudo pip install mysql-python"和我得到的信息,

Collecting mysql-python
  Downloading MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 110kB 1.4MB/s 
    Complete output from command python setup.py egg_info:
    sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 20, in <module>
      File "/private/tmp/pip-build-EdaCnd/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 /private/tmp/pip-build-EdaCnd/mysql-python

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

您需要安装mysql_config。在Debian / Ubuntu上,您将使用此命令进行安装:

sudo apt-get install libmysqlclient-dev

假设您拥有计算机的管理员权限。也可能是mysql_config不在您的路径中,您也应该查看它。