0

sudo apt-get install python-apt

returning error:

python-apt : Depends: python (<2.8) but 3.3.3-1 is to be installed

I have removed python3 from the machine using apt-get

When I run:

dpkg-query --list

I get the following for python:

ri python 3.3.3-1 python-3.3.3
ii python2.7 2.7.3-0ubuntu3

but by running python --version

Python 2.7.3

How can I remove any of the python 3.3.3-1 references/packages from my system?

 apt-cache policy python python2 python3
python:
  Installed: 3.3.3-1
  Candidate: 3.3.3-1
  Version table:
 *** 3.3.3-1 0
        100 /var/lib/dpkg/status
     2.7.3-0ubuntu2.2 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
     2.7.3-0ubuntu2 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
python3:
  Installed: (none)
  Candidate: 3.2.3-0ubuntu1.2
  Version table:
     3.2.3-0ubuntu1.2 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
     3.2.3-0ubuntu1 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
N: Unable to locate package python2

After Byte Commander's comment:

 apt-cache policy python
python:
  Installed: 2.7.3-0ubuntu2.2
  Candidate: 2.7.3-0ubuntu2.2
  Version table:
 *** 2.7.3-0ubuntu2.2 0
        500 http://gb.archive.ubuntu.com/ubuntu/ precise-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.7.3-0ubuntu2 0
    500 http://gb.archive.ubuntu.com/ubuntu/ precise/main amd64 Packages
  • Can you add the output of apt policy python python2 python3 to your question, please? But most importantly, don't mess with the Python if you are not sure what you are doing! Many of Ubuntu's applications (like e.g. the apt package manager itself) depend on Python and will no longer work after you remove it. The goal here is not to uninstall Python (except if you installed additional Pythons yourself, but not the system packages). – Byte Commander Apr 8 '17 at 13:23
  • I'm assuming you mean apt-cache policy? I've added it above. – Alex Apr 9 '17 at 8:27
  • Okay, so for whatever reason you have a python package in your local package cache which provides Python 3, although it should be Python 2. If you hopefully haven't messed up too much yet and apt-get still works, try running this: sudo apt-get install python=2.7.3-0ubuntu2.2 python3 and remove your cached packages with sudo apt-get clean afterwards. Please reply back whether it worked and post its output, together with the output of apt-cache policy python again. – Byte Commander Apr 9 '17 at 9:40
  • After everything got fixed again, you should probably also check your /var/log/apt/history.log and see which packages got removed when you uninstalled python3 earlier (which you should not have done) and reinstall them again. – Byte Commander Apr 9 '17 at 9:41
  • fwiw, whenever you think you need to do something with a Python installation, consider using Docker. Alpine Linux is only about 8MB. Because messing with the default Python installation on Debian/Ubuntu can result in the OS no longer working. – Daniel F Nov 19 '17 at 11:58
1

Okay, so for whatever reason you have a python package in your local package cache which provides Python 3, although it should be Python 2.

If you hopefully haven't messed up too much yet and apt-get still works, try running this:

sudo apt-get install python=2.7.3-0ubuntu2.2 python3 

and remove your cached packages with

sudo apt-get clean

afterwards.

After everything got fixed again, you should probably also check your /var/log/apt/history.log and see which packages got removed when you uninstalled python3 earlier (which you should not have done) and reinstall them again.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.