centos 安装mysqlclient 失败 报错


报错信息

Using cached https://pypi.tuna.tsinghua.edu.cn/packages/6a/91/bdfe808fb5dc99a5f65833b370818161b77ef6d1e19b488e4c146ab615aa/mysqlclient-1.3.0.tar.gz (76 kB)
ERROR: Command errored out with exit status 1:
command: /root/.virtualenvs/zhongbao/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/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-tv2tvpzi
cwd: /tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/
Complete output (10 lines):
/bin/sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/setup.py", line 17, in <module>
metadata, options = get_config()
File "/tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/setup_posix.py", line 47, in get_config
libs = mysql_config("libs_r")
File "/tmp/pip-install-_0nm0v_4/mysqlclient_663d3dd955824198949aa04e326f95ed/setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
OSError: mysql_config not found
----------------------------------------
WARNING: Discarding https://pypi.tuna.tsinghua.edu.cn/packages/6a/91/bdfe808fb5dc99a5f65833b370818161b77ef6d1e19b488e4c146ab615aa/mysqlclient-1.3.0.tar.gz#sha256=06eb5664e3738b283ea2262ee60ed83192e898f019cc7ff251f4d05a564ab3b7 (from https://pypi.tuna.tsinghua.edu.cn/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
ERROR: No matching distribution found for mysqlclient

解决方法

yum install mysql-devel
pip install mysqlclient