Ubuntu 20.04 python2安装pip

Ubuntu 20已经无法通过apt来安装python2的pip2了,只能安装python3的pip

方法

先确保你有python2

# 暂时还是可以用apt安装python2
sudo apt install python2
# 下面这个链接可能会失效,不过会提示你去新的链接下载,把链接换了就可以。
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
sudo python2 get-pip.py

接下来你就可以用指定的python pip安装包啦

# 用以下方式指定安装python2的包,比如numpy
python2 -m pip install numpy

例子

edward@ubuntu ~> wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
--2021-09-15 20:15:41--  https://bootstrap.pypa.io/pip/2.7/get-pip.py
Resolving bootstrap.pypa.io (bootstrap.pypa.io)... 151.101.72.175, 2a04:4e42:1a::175
Connecting to bootstrap.pypa.io (bootstrap.pypa.io)|151.101.72.175|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1908226 (1.8M) [text/x-python]
Saving to: ‘get-pip.py’

get-pip.py          100%[==================>]   1.82M  1.41MB/s    in 1.3s

2021-09-15 20:15:43 (1.41 MB/s) - ‘get-pip.py’ saved [1908226/1908226]

edward@ubuntu ~> sudo python2 get-pip.py
[sudo] password for edward:
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 pip 21.0 will remove support for this functionality.
Collecting pip<21.0
 Downloading pip-20.3.4-py2.py3-none-any.whl (1.5 MB)
    |████████████████████████████████| 1.5 MB 749 kB/s
Collecting setuptools<45
 Downloading setuptools-44.1.1-py2.py3-none-any.whl (583 kB)
    |████████████████████████████████| 583 kB 2.1 MB/s
Collecting wheel
 Downloading wheel-0.37.0-py2.py3-none-any.whl (35 kB)
Installing collected packages: pip, setuptools, wheel
Successfully installed pip-20.3.4 setuptools-44.1.1 wheel-0.37.0

你可能感兴趣的:(机器人系统,ubuntu,linux,运维)