apt-get update not Working due to unmet dependencies

Solution 1:

It seems that python installation is broken .. Try reinstalling python3-minimal

sudo apt-get install --reinstall python3-minimal

Now you can run sudo apt-get install --fix-broken again and then apt-get update .. if this fails let us know.

Solution 2:

I too experienced this problem - in my case on Raspbian when upgrading from wheezy to jessie. The python3-minimal package was left in a bad state, with prerm and postinst hook scripts for debconf failing when calling the py3clean and py3compile commands.

Indeed py3clean was broken as seen when running the command directly:

-bash: /usr/bin/py3clean: /usr/bin/python3: bad interpreter: No such file or directory

Attempting to reinstall the python3-minimal package resulted in an error:

$ sudo apt-get install --reinstall python3-minimal
Reading package lists... Done
Building dependency tree
Reading state information... Done
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 idle3 : Depends: idle-python3.4 but it is not going to be installed
 python3 : Depends: python3.4 (>= 3.4.2-0) but it is not going to be installed
           Depends: libpython3-stdlib (= 3.4.2-2) but it is not going to be installed
           Depends: dh-python but it is not going to be installed
 python3-minimal : Depends: python3.4-minimal (>= 3.4.2-0) but it is not going to be installed
 python3-numpy : Depends: python3.4 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

The suggested apt-get -f install command remained broken.

Ultimately I worked around the problem by commenting out the py3clean-related lines from /var/lib/dpkg/info/debconf.prerm which looked something like:

if which py3clean >/dev/null 2>&1; then
       py3clean -p debconf 
fi

I then had to comment out the py3compile lines from /var/lib/dpkg/info/debconf.postinst:

if which py3compile >/dev/null 2>&1; then
       py3compile -p debconf 
fi

That allowed me to successfully run

sudo apt-get -f install

At this point I was able to reinstall the package cleanly, which also handily removed the above script customisations which were no longer needed.

sudo apt-get install --reinstall debconf