0

I have made a huge mistake on my Ubuntu 16.04 server.

I compiled and installed Python 3.7.0 from source using make altinstall, but I did not include all of the core dependencies I needed, so I was going to remove it and install a pre-packaged deb instead.

However, to remove it, I used this method with checkinstall. I generated a deb so that I could then remove all of the files created by the original installation, but for the deb's package name, I just left the default python.

Now, I have the following package installed:

$ sudo dpkg -l python
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
ri  python                                                3.7.0-1                         amd64                           Package created with checkinstall 1.6.2

This means that I cannot run dpkg -r python because system packages depend on a metapackage just called python:

$ sudo dpkg -r python
dpkg: dependency problems prevent removal of python:
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-ldb depends on python (<< 2.8).
 python-ldb depends on python (>= 2.7~).
 python-talloc depends on python (<< 2.8).
 python-talloc depends on python (>= 2.7~).
 python-talloc depends on python (<< 2.8).
 python-talloc depends on python (>= 2.7~).
 python-pyicu depends on python (>= 2.7).
 python-pyicu depends on python (<< 2.8).
 python-pyicu depends on python (>= 2.7).
 python-pyicu depends on python (<< 2.8).
 samba-common-bin depends on python.
 samba depends on python (>= 2.7).
 samba depends on python (<< 2.8).
 samba depends on python (>= 2.7).
 samba depends on python (<< 2.8).
 iotop depends on python (>= 2.7.1-0ubuntu2).
 iotop depends on python (<< 2.8).
 iotop depends on python (>= 2.7.1-0ubuntu2).
 iotop depends on python (<< 2.8).
 python-cryptography depends on python (<< 2.8).
 py
dpkg: error processing package python (--remove):
 dependency problems - not removing
Errors were encountered while processing:
 python

And I cannot install the default version of python again because I have the wrong version installed for python:

$ sudo apt install python
Reading package lists... Done
Building dependency tree       
Reading state information... Done
python is already the newest version (3.7.0-1).
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 iotop : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-acme : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-asn1crypto : Depends: python:any (< 2.8)
                     Depends: python:any (>= 2.7.5-5~)
 python-certifi : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-cffi-backend : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-chardet : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-configparser : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-crypto : Depends: python (< 2.8) but 3.7.0-1 is to be installed
                 Depends: python:any (>= 2.7.5-5~)
 python-cryptography : Depends: python (< 2.8) but 3.7.0-1 is to be installed
                       Depends: python:any (>= 2.7.5-5~)
 python-dnspython : Depends: python:any (< 2.8)
                    Depends: python:any (>= 2.7.5-5~)
 python-enum34 : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-funcsigs : Depends: python:any (< 2.8)
                   Depends: python:any (>= 2.7.5-5~)
 python-future : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-idna : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-ipaddress : Depends: python:any (< 2.8)
                    Depends: python:any (>= 2.7.5-5~)
 python-josepy : Depends: python:any (< 2.8)
                 Depends: python:any (>= 2.7.5-5~)
 python-ldb : Depends: python (< 2.8) but 3.7.0-1 is to be installed
              Depends: python:any (>= 2.7.5-5~)
 python-mock : Depends: python:any (< 2.8)
               Depends: python:any (>= 2.7.5-5~)
 python-openssl : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-parsedatetime : Depends: python:any (< 2.8)
                        Depends: python:any (>= 2.7.5-5~)
 python-pbr : Depends: python:any (< 2.8)
              Depends: python:any (>= 2.7.5-5~)
 python-pkg-resources : Depends: python:any (< 2.8)
                        Depends: python:any (>= 2.7.5-5~)
 python-pyicu : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-requests : Depends: python:any (< 2.8)
                   Depends: python:any (>= 2.7.5-5~)
 python-requests-toolbelt : Depends: python:any (< 2.8)
                            Depends: python:any (>= 2.7.5-5~)
 python-rfc3339 : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 python-samba : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-setuptools : Depends: python:any (< 2.8)
                     Depends: python:any (>= 2.7.5-5~)
 python-six : Depends: python:any (< 2.8)
              Depends: python:any (>= 2.7.5-5~)
 python-talloc : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-tdb : Depends: python (< 2.8) but 3.7.0-1 is to be installed
              Depends: python:any (>= 2.7.5-5~)
 python-tz : Depends: python (< 2.8) but 3.7.0-1 is to be installed
 python-urllib3 : Depends: python:any (< 2.8)
                  Depends: python:any (>= 2.7.5-5~)
 samba : Depends: python (< 2.8) but 3.7.0-1 is to be installed
         Recommends: attr but it is not going to be installed
         Recommends: samba-dsdb-modules but it is not going to be installed
         Recommends: samba-vfs-modules but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Running that scares me, so I chose no:

$ sudo apt-get -f install
Reading package lists... Done
Building dependency tree       
Reading state information... Done
Correcting dependencies... Done
The following packages will be REMOVED:
  iotop python-acme python-asn1crypto python-certifi python-cffi-backend python-chardet python-configparser python-crypto python-cryptography python-dnspython python-enum34 python-funcsigs python-future python-idna python-ipaddress
  python-josepy python-ldb python-mock python-openssl python-parsedatetime python-pbr python-pkg-resources python-pyicu python-requests python-requests-toolbelt python-rfc3339 python-samba python-setuptools python-six python-talloc
  python-tdb python-tz python-urllib3 samba samba-common-bin samba-libs
0 upgraded, 0 newly installed, 36 to remove and 0 not upgraded.
After this operation, 56.7 MB disk space will be freed.
Do you want to continue? [Y/n]

Is there any way to recover from this? Thanks in advance!

5
  • 3
    sudo apt-get dist-upgrade would be my first choice. Apr 1, 2019 at 4:27
  • @MichaelHampton Thanks for the suggestion, but it wants to do the same thing as apt-get -f install Apr 1, 2019 at 13:51
  • It wanted to remove exactly the same set of packages? That doesn't make sense. Can you copy and paste the output you saw? Apr 1, 2019 at 15:17
  • @MichaelHampton Sure thing: pastebin.com/HNvAuGWc Apr 1, 2019 at 15:31
  • That's very different output, and it should also be in your question. Apr 1, 2019 at 15:36

1 Answer 1

1

Normally an apt-get dist-upgrade will sort this out, by replacing packages with those in the actual apt sources you have enabled, but it doesn't seem to have done so this time on your system.

It looks like you're going to find a way need to reinstall the original Python package.

Fortunately you can do this by specifying the package version you want.

But first you have to figure out what that version is. For that, use apt policy. You should see something similar to this:

error@vmtest-ubuntu1604:~$ sudo apt policy python
python:
  Installed: 3.7.0-1
  Candidate: 2.7.12-1~16.04
  Version table:
 *** 2.7.12-1~16.04 500
        500 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.7.11-1 500
        500 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 Packages

Now that you have its version number, you can install it specifically:

error@vmtest-ubuntu1604:~$ sudo apt install python=2.7.12-1~16.04 

(Don't use -f here, even if prompted.)

1
  • This worked perfectly! Thank you for an easy solution :) Apr 1, 2019 at 16:01

You must log in to answer this question.

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