linux会自带python2

但是没有pip模块,不能安装三方库

这里为Python2 安装pip模块

安装依赖

yum -y install epel-release

安装pip

yum install python-pip

验证

pip -V

报错

    Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==21.1.3', '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/__init__.py", line 1, in <module>
    from typing import List, Optional
ImportError: No module named typing

解决办法

yum remove python-pip  
cd /usr/local/src
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
python get-pip.py  
pip -V
Last modification:July 2nd, 2021 at 01:27 pm
如果觉得我的文章对你有用,请随意赞赏