場景
[root@test ~]# pip install MySQLdbpip install MySQLdb
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 https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Looking in indexes: http://mirrors.tencentyun.com/pypi/simple
ERROR: Could not find a version that satisfies the requirement MySQLdb (from versions: none)
ERROR: No matching distribution found for MySQLdb
解決
直接官網(wǎng)下載安裝包
下載zip壓縮包上傳到服務(wù)器后解壓縮
[root@test soft]# chmod 755 MySQL-python-1.2.5.zip
[root@test soft]# unzip MySQL-python-1.2.5.zip
[root@test soft]# cd MySQL-python-1.2.5/
[root@test MySQL-python-1.2.5]# python setup.py install
sh: mysql_config: 未找到命令
Traceback (most recent call last):
File "setup.py", line 17, in <module>
metadata, options = get_config()
File "/home/soft/MySQL-python-1.2.5/setup_posix.py", line 43, in get_config
libs = mysql_config("libs_r")
File "/home/soft/MySQL-python-1.2.5/setup_posix.py", line 25, in mysql_config
raise EnvironmentError("%s not found" % (mysql_config.path,))
EnvironmentError: mysql_config not found
此時(shí)可能會(huì)報(bào)以上錯(cuò)誤
解決
[root@test MySQL-python-1.2.5]# yum install mysql-devel
安裝后再次執(zhí)行python setup.py install
搞定