2

I'm trying to install some packages with apt-get on ubuntu but I get a similar error on a couple of them. It would appear that there is something wrong with my python packages since I get the message "You have held broken packages".

~$ sudo apt-get install ranger 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 to resolve the situation:

The following packages have unmet dependencies:  ranger : Depends: python:any (< 2.8)
          Depends: python:any (>= 2.7.5-5~)
          Recommends: python-chardet but it is not going to be installed E: Unable to correct problems, you have held broken packages.

~$  python -V
Python 2.7.13
~$  python3 -V
Python 3.5.2

dpkg --get-selections | grep hold gives me nothing, so I can't seem to find what's being held. As with the above output, both python 2, which came with ubuntu and python 3 which was installed by me is there, however I still get the error. Is this a symptom of me inproperly installing python, or is there another fix for this?

2

The problem appears to have been that I manually installed Python to a more recent version than the distribution provides. When the apt-get tries to repair the installation it needs to downgrade, which is only possible if you specify that it should.

Creating a file /etc/apt/preferences.d/allow-downgrade containing

Package: *
Pin: release o=Ubuntu
Pin-Priority: 1001

and then running

apt-get update
apt-get upgrade
apt-get -f install
apt-get update

solved the problem.

For source and a more detailed answer:

https://unix.stackexchange.com/questions/218911/help-me-repair-my-python-i-think-dpkg-has-to-be-reset-very-tricky-issue

  • 2
    Whatever this solution did was way over my head, but this is the only one of the dozens of 'broken packages' solutions I've found that worked – Brandon Apr 15 '17 at 21:42

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.