Ubuntu 18.04.2 install python2.7, unmet dependency

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 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 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 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 bionic-updates/main amd64 Packages 500 bionic-security/main amd64 Packages 100 /var/lib/dpkg/status 2.7.15~rc1-1 500 500 bionic/main amd64 Packages
3

1 Answer

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

sudo apt purge libpython2*

Then install python2 :

sudo apt install python

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like