Ubuntu 18.04.2安装python2.7,未满足的依赖关系

Ubuntu 18.04.2安装python2.7,未满足的依赖关系

我无法在我的 ubuntu 18.04.2 上安装 python2,下面是我所做的:

bo@ubuntu18:~$ sudo apt install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help resolve the situation:

The following packages have unmet dependencies:
 python : PreDepends: python-minimal (= 2.7.15~rc1-1) but it is not going to be installed
          Depends: python2.7 (>= 2.7.15~rc1-1~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

于是一步一步,我发现问题的根源是我无法在笔记本电脑上安装 libpython2.7:

The following packages have unmet dependencies:
 python2.7-minimal : Depends: libpython2.7-minimal (= 2.7.15~rc1-1) but 2.7.15~rc1-1ubuntu0.1 is to be installed
                     Recommends: python2.7 but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

有谁知道如何解决这个问题?


输出apt-cache policy python libpython2.7-minimal

bo@ubuntu18:~$ apt-cache policy python libpython2.7-minimal
python:
  Installed: (none)
  Candidate: 2.7.15~rc1-1
  Version table:
     2.7.15~rc1-1 500
        500 http://mirror.clibre.uqam.ca/ubuntu bionic/main amd64 Packages
libpython2.7-minimal:
  Installed: 2.7.15~rc1-1ubuntu0.1
  Candidate: 2.7.15~rc1-1ubuntu0.1
  Version table:
 *** 2.7.15~rc1-1ubuntu0.1 100
        100 /var/lib/dpkg/status
     2.7.15~rc1-1 500
        500 http://mirror.clibre.uqam.ca/ubuntu bionic/main amd64 Packages

然后我换了一个软件源,更新了一些东西。现在可以正常工作了。

bo@ubuntu18:~$ apt-cache policy python libpython2.7-minimal
python:
  Installed: 2.7.15~rc1-1
  Candidate: 2.7.15~rc1-1
  Version table:
 *** 2.7.15~rc1-1 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic/main amd64 Packages
        100 /var/lib/dpkg/status
libpython2.7-minimal:
  Installed: 2.7.15-4ubuntu4~18.04.1
  Candidate: 2.7.15-4ubuntu4~18.04.1
  Version table:
 *** 2.7.15-4ubuntu4~18.04.1 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
        500 http://ca.archive.ubuntu.com/ubuntu bionic-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2.7.15~rc1-1 500
        500 http://ca.archive.ubuntu.com/ubuntu bionic/main amd64 Packages

答案1

你只需要使用以下命令卸载已经安装的 python2 包:

sudo apt purge libpython2*

然后安装 python2:

sudo apt install python

相关内容