3

I cannot install python2 on my ubuntu 18.04.2, below are what I did:

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.

So step by step, I found the source problem is that I cannot install libpython2.7 on my laptop:

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.

Does anyone know how to resolve this problem?


The output of 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

Then I changed a software source and updated something. It works.

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
3
  • Looks like you are trying to install the package from some non-Ubuntu source, or you tried (and perhaps failed) to install and didn't clean up afterward. Use apt-cache policy libpython2.7-minimal to determine which non-Ubuntu or obsolete source the 2.7.15~rc1-1ubuntu0.1 version is coming from, then disable that source, then run sudo apt update to refresh your package database from the remaining (valid) sources.
    – user535733
    Sep 15, 2019 at 3:25
  • Please add output of apt-cache policy python libpython2.7-minimal to the question.
    – N0rbert
    Sep 15, 2019 at 9:35
  • I have added the apt-cache policy python libpython2.7-minimal's output. @user535733 @N0rbert
    – Bai Yang
    Sep 15, 2019 at 12:19

1 Answer 1

7

you just have to uninstall already installed python2 packages with this :

sudo apt purge libpython2*

Then install python2 :

sudo apt install python

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .