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
  • 6
    点赞
  • 16
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值