安装mysqlclient报错

时间:2024-03-09 10:33:14

简介:

  在python虚拟环境中执行 pip install mysqlclient==1.3.10 报错以下错误:

  

   ERROR: Command errored out with exit status 1:
     command: /python/opsmind_env/bin/python3 -c \'import sys, setuptools, tokenize; sys.argv[0] = \'"\'"\'/tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/setup.py\'"\'"\'; __file__=\'"\'"\'/tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/setup.py\'"\'"\';f=getattr(tokenize, \'"\'"\'open\'"\'"\', open)(__file__);code=f.read().replace(\'"\'"\'\r\n\'"\'"\', \'"\'"\'\n\'"\'"\');f.close();exec(compile(code, __file__, \'"\'"\'exec\'"\'"\'))\' egg_info --egg-base /tmp/pip-pip-egg-info-ygsal_9n
         cwd: /tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/
    Complete output (10 lines):
    /bin/sh: mysql_config: command not found
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/setup.py", line 17, in <module>
        metadata, options = get_config()
      File "/tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/setup_posix.py", line 44, in get_config
        libs = mysql_config("libs_r")
      File "/tmp/pip-install-dq7fi39z/mysqlclient_c913fe4ca8a04a0c80ac6f784e022981/setup_posix.py", line 26, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    OSError: mysql_config not found
    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/40/9b/0bc869f290b8f49a99b8d97927f57126a5d1befcf8bac92c60dc855f2523/mysqlclient-1.3.10.tar.gz#sha256=452aaf9d2ba1a4fb85c134c88f9b1857852deed63b3b13255d7a65d2c1297262 (from https://pypi.org/simple/mysqlclient/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement mysqlclient==1.3.10
ERROR: No matching distribution found for mysqlclient==1.3.10

 

解决方式:

  yum install -y python3-devel mysql-devel

 

补充:mysqlclient 其他版本相同错误也可以这样解决