内置python2.7升级pip后不可用的解决办法
1.centos7内置python,安装pip yum install -y python-pip 后,在使用pip中有一些库安装会提示升级pip,但升级后,pip不可用了
2.解决方法1:卸载重装pip:yum remove -y python-pip && yum install -y python-pip
3.若方法1操作后任然不行,报错如下,此时删除/usr/lib/python2.7/site-packages/logging即可:mv /usr/lib/python2.7/site-packages/logging /usr/lib/python2.7/site-packages/logging.bak
=======================================================
升级后提示:ImportError: No module named typing
原因是:pip21和python2.7不配套,报错里面的typing库是python3.5才出现的,python2.7版本没有这个库。
解决办法:
1.yum remove -y python-pip && yum install -y python-pip 2.python -m pip install --upgrade "pip < 21.0" 3.pip install aliyun-python-sdk-cdn
4.报错:sys.stderr.write(f"ERROR: {exc}")
[root@VM-0-7-centos:root script]# pip install aliyun-python-sdk-cdn Traceback (most recent call last): File "/usr/bin/pip", line 9, in <module> load_entry_point('pip==21.0', 'console_scripts', 'pip')() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point return get_distribution(dist).load_entry_point(group, name) File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point return ep.load() File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load entry = __import__(self.module_name, globals(),globals(), ['__name__']) File "/usr/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60 sys.stderr.write(f"ERROR: {exc}") ^ SyntaxError: invalid syntax
解决:
使用get-pip.py安装pip
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py python2 get-pip.py
一些事情一直在干,说不定以后就结果了呢
本文来自博客园,作者:chenjianwen,转载请注明原文链接:https://www.cnblogs.com/chenjw-note/p/15022904.html