Ubuntu 20.04 最低版本:“无法找到软件包 python-pip”

Ubuntu 20.04 最低版本:“无法找到软件包 python-pip”

在 GCP 中启动一些小型虚拟机,我想尝试一下 Ubuntu 20.04 LTS 最低版本。执行“apt update; apt upgrade”后,我可以安装像 Apache 这样的软件包,但使用 PIP 却毫无运气:

root@ubuntu-rr58:/home/me# apt install python-pip
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E: Unable to locate package python-pip

我已经验证了 Universe、Multiverse 和 Restricted 存储库可用:

root@ubuntu-rr58:~# grep ^deb /etc/apt/sources.list
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal main restricted
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal-updates main restricted
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal universe
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal-updates universe
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal multiverse
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal-updates multiverse
deb http://us-central1.gce.archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu focal-security main restricted
deb http://security.ubuntu.com/ubuntu focal-security universe
deb http://security.ubuntu.com/ubuntu focal-security multiverse

答案1

该软件包名为python3-pip。Ubuntu 20.04 不再附带 Python 2.7,现在几乎所有与 Python 相关的软件包都称为python3-*

答案2

要恢复 Python 2 版本的 pip,你可以使用获取pip,这是一个下载并安装最新版本的 pip 的脚本(适用于 Python 2 或 3,无论使用哪个版本运行脚本):

$ curl -O https://raw.githubusercontent.com/pypa/get-pip/master/get-pip.py
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1824k  100 1824k    0     0  2211k      0 --:--:-- --:--:-- --:--:-- 2211k

$ python get-pip.py 
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
Defaulting to user installation because normal site-packages is not writeable
Collecting pip
  Using cached pip-20.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.1
    Uninstalling pip-20.1:
      Successfully uninstalled pip-20.1
  WARNING: The scripts pip, pip2 and pip2.7 are installed in '~/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-20.1

然后添加~/.local/bin/到您的 PATH(例如在您的~/.bashrc):

PATH=$HOME/.local/bin/:$PATH

之后,您应该有一个pip适用于 Python 2 的工作命令。或者,如果您想确保您的目标不是 Python 3,请使用pip2/ 。pip2.7

相关内容