python: 报错 Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-BqMhb7/matplotlib, /tmp/pip-install-uc5u0zxb/mysqlclient/

 

运行

pip install mysqlclient

的是报错

The directory '/home/justcode/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/justcode/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting mysqlclient
  Downloading https://files.pythonhosted.org/packages/f7/a2/1230ebbb4b91f42ad6b646e59eb8855559817ad5505d81c1ca2b5a216040/mysqlclient-1.3.14.tar.gz (91kB)
    100% |████████████████████████████████| 92kB 3.9MB/s 
    Complete output from command python setup.py egg_info:
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-uc5u0zxb/mysqlclient/setup.py", line 16, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-uc5u0zxb/mysqlclient/setup_posix.py", line 53, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-uc5u0zxb/mysqlclient/setup_posix.py", line 28, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-uc5u0zxb/mysqlclient/

 

解决方法:

sudo pip install --upgrade setuptools
sudo apt-get install python3.6-dev libmysqlclient-dev

 

参考:Python:Mysql连库及简单封装使用, python mysql操作类

 

本文:python: 报错 Command “python setup.py egg_info” failed with error code 1 in /tmp/pip-build-BqMhb7/matplotlib, /tmp/pip-install-uc5u0zxb/mysqlclient/

Leave a Reply