场景
[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
解决
直接官网下载安装包
下载zip压缩包上传到服务器后解压缩
[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
此时可能会报以上错误
解决
[root@test MySQL-python-1.2.5]# yum install mysql-devel
安装后再次执行python setup.py install
搞定