解决python安装mysqlclient出现“/bin/sh:1:mysql_config:not found”错误

在安装mysqlcient的时候出现这个错误

Collecting mysqlclient==1.3.12 (from -r requirements.txt (line 10))
  Downloading https://pypi.doubanio.com/packages/6f/86/bad31f1c1bb0cc99e88ca2adb7cb5c71f7a6540c1bb001480513de76a931/mysqlclient-1.3.12.tar.gz (89kB)
    100% |████████████████████████████████| 92kB 1.5MB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-8j6zqrk9/mysqlclient/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-8j6zqrk9/mysqlclient/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-8j6zqrk9/mysqlclient/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found

解决方法很简单只要在系统中安装libmysqlclient-dev后在安装mysqlclient依赖就可以了。

apt-get install libmysqlclient-dev

本博客采用 知识共享署名-禁止演绎 4.0 国际许可协议 进行许可

本文标题:解决python安装mysqlclient出现“/bin/sh:1:mysql_config:not found”错误

本文地址:https://jizhong.plus/post/2018/04/python-mysqlclient-error.html