mysql-python安裝時Environment Error: mysql_config not found

weixin_34138377發表於2018-05-16

在安裝 mysql-python時,出現:

Collecting MySQL-python
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a5/e9/51b544da85a36a68debe7a7091f068d802fc515a3a202652828c73453cad/MySQL-python-1.2.5.zip (108kB)
    100% |████████████████████████████████| 112kB 2.1MB/s
    Complete output from command python setup.py egg_info:
    sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-vkUfD6/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

可能是因為沒有安裝:libmysqlclient-dev

執行以下命令安裝:

sudo apt-get install python-dev libmysqlclient-dev

安裝後再次執行安裝 mysql-python命令:

pip install MySQL-python

成功安裝:

參考來源:mysql-python安裝時EnvironmentError: mysql_config not found

相關文章