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
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 runsudo apt update
to refresh your package database from the remaining (valid) sources.apt-cache policy python libpython2.7-minimal
to the question.apt-cache policy python libpython2.7-minimal
's output. @user535733 @N0rbert