python中安装mysqldb包一直失败

Collecting Flask-MySQLdb
Using cached Flask-MySQLdb-0.2.0.tar.gz (2.1 kB)
Collecting Flask>=0.10
Using cached Flask-1.1.4-py2.py3-none-any.whl (94 kB)
Collecting mysqlclient
Using cached mysqlclient-1.4.6.tar.gz (85 kB)

DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at

pip 21.0 will remove support for this functionality.
ERROR: Command errored out with exit status 1:
command: /Users/v_lifei08/Documents/zhengwu/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/k2/lnjwczgn30d4hlv80q2sd07m0000gn/T/pip-install-0sBAJR/mysqlclient/setup.py'"'"'; file='"'"'/private/var/folders/k2/lnjwczgn30d4hlv80q2sd07m0000gn/T/pip-install-0sBAJR/mysqlclient/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 /private/var/folders/k2/lnjwczgn30d4hlv80q2sd07m0000gn/T/pip-pip-egg-info-XfnQOF
cwd: /private/var/folders/k2/lnjwczgn30d4hlv80q2sd07m0000gn/T/pip-install-0sBAJR/mysqlclient/
Complete output (12 lines):
sh: mysql_config: command not found
sh: mariadb_config: command not found
sh: mysql_config: command not found
Traceback (most recent call last):
File "", line 1, in
File "/private/var/folders/k2/lnjwczgn30d4hlv80q2sd07m0000gn/T/pip-install-0sBAJR/mysqlclient/setup.py", line 16, in
metadata, options = get_config()
File "setup_posix.py", line 61, in get_config
libs = mysql_config("libs")
File "setup_posix.py", line 29, in mysql_config
raise EnvironmentError("%s not found" % (_mysql_config_path,))
EnvironmentError: mysql_config not found
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

博主,可能是你的pip版本过低无法使用。你可以更新成最新pip或者重新装。
链接在这(或许有帮助):