centos6 升级pip后导致pip不可用

问题:公司内部一台服务器在用pip安装python某个模块的时候提示pip需要升级,然后我就手贱升级了一下,结果悲催了,再次执行pip命令时报错如下:

Google了下错误,说是:

CENTOS/RHEL 6 PYTHON PIP ERROR, SYNTAXERROR: INVALID SYNTAX {STR(C.VERSION) FOR C IN ALL_CANDIDATES}

If you’re attempting to upgrade the version of PIP on CentOS or RHEL 6 from the default 7.1.0 to a newer version, as of April 14th 2018 when PIP 10.0.0 was released you will run into issues since EL6 ships with Python 2.6 as standard. Since you cannot upgrade the default version of Python because it will break in-built tooling such as Yum, you’ll need to version lock PIP when you upgrade it to 9.0.3. This is the last stable version of PIP that is compatible with Python 2.6

用百度翻译了下(可以看出应该是兼容性的问题):

如果您试图将CentOS或Rhel 6上的PIP版本从默认的7.1.0升级到较新的版本,截至2018年4月14日PIP 10.0.0发布时,您将遇到问题,因为EL6以python 2.6为标准提供。由于不能升级默认版本的python,因为它会破坏内置的工具(如yum),所以在将其升级到9.0.3时,需要对pip进行版本锁定。这是与python 2.6兼容的pip的最后一个稳定版本。

解决办法:

#yum list python-pip
#yum erase python-pip  --删除
#pip  --再次执行pip时报命令不存在,说明已经卸载了
#yum -y install python-pip  --重新安装

原文地址:https://www.cnblogs.com/liangyou666/p/10786028.html