11

enter image description here

After upgraded my Ubuntu to 17.04, the package system is broken. When I execute any of the following commands, I got some error.

sudo apt-get --fix-broken install

$ sudo apt-get --fix-broken install
...
...
ubuntuone-credentials-common unity-plugin-scopes unity-scope-
mediascanner2
  unity-webapps-qml url-dispatcher usermetricsservice vbetool vlc-nox
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  click-apparmor
The following packages will be upgraded:
  click-apparmor
1 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
Need to get 0 B/10.7 kB of archives.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n] y
(Reading database ... 625249 files and directories currently installed.)
Preparing to unpack .../click-apparmor_0.3.18_amd64.deb ...
Cannot start click due to a conflict with a different locally-installed Python 'click' package.  Remove it using Python packaging tools and try again.
dpkg: warning: subprocess old pre-removal script returned error exit status 1
dpkg: trying script from the new package instead ...
Cannot start click due to a conflict with a different locally-installed Python 'click' package.  Remove it using Python packaging tools and try again.
dpkg: error processing archive /var/cache/apt/archives/click-apparmor_0.3.18_amd64.deb (--unpack):
 subprocess new pre-removal script returned error exit status 1
Errors were encountered while processing:
 /var/cache/apt/archives/click-apparmor_0.3.18_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

sudo apt-get full-upgrade

$ sudo apt-get full-upgrade
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 click-apparmor : Depends: python3-apparmor-click (= 0.3.17) but 0.3.18 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

I also have tried the following solutions but they did not work.

Anyone know how to fix it without reinstalling Ubuntu?

  • 1
    I have the same problem. I tried the fixes proposed here and here but nothing worked. – guillaume8375 Apr 15 '17 at 11:14
8

I think I found a solution, but a big caveat though: it works, but I can’t explain why.

First, I went to /var/lib/dpkg/info/:

cd /var/lib/dpkg/info/

Then, I removed the lines pertaining to the packages which caused the problems. In my case, I had to do:

sudo rm -r python3-apparmor-click.*
sudo rm -r click-apparmor.*
sudo rm -r click.*
sudo rm -r ubuntu-app-launch.* 
sudo rm -r url-dispatcher-tools.*
sudo rm -r url-dispatcher:amd64.*
sudo rm -r libunity-scopes1.0:amd64

After that, I typed:

sudo apt purge python3-apparmor-click
sudo apt purge click-apparmor    
sudo apt purge click
sudo apt purge ubuntu-app-launch
sudo apt purge url-dispatcher-tools
sudo apt purge url-dispatcher:amd64
sudo apt purge libunity-scopes1.0

After that,

sudo apt update

And finally,

sudo apt dist-upgrade

which worked and updated my packages. All the packages problems seem to have disappeared.

  • 1
    The command apt purge returns E: Sub-process /usr/bin/dpkg returned an error code (1). – Kin Apr 16 '17 at 11:37
  • @Casper For every package? – guillaume8375 Apr 16 '17 at 13:01
  • Yes. It seems so. – Kin Apr 17 '17 at 5:38
  • I also had to use aptitude to purge dependencies, apt / apt-get command was not able to do it askubuntu.com/questions/1085665/… – baptx Oct 21 '18 at 18:02
7
+25

I had the same problem after upgrading to Ubuntu 17.04, this worked for me:

sudo -H pip3 uninstall click
sudo apt install python3-click-package
sudo apt upgrade
sudo apt autoremove

Not sure why (perhaps pip's click version is different than the one Ubuntu depends on?) but this fixed the issue.

  • pip3 uninstall click removes the click module that was installed via Pip for Python 3 which would likely fix the complaint during the package installation in OP's question as it is the most common installation method for Python modules on Ubuntu outside of Apt. Another options is that they used easyinstall or something like make install. – David Foerster Apr 22 '17 at 11:40
5

First remove python 'click' package using pip:

pip uninstall click

If you using python3 : pip3 uninstall click

Then fix the packages by apt:

sudo apt clean
sudo apt install -f 
1

This seemed to solve the problem for me (at least I do not get error messages any more):

I did a sudo apt autoremove and noted the packages with unmet dependencies:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 bind9-host : Depends: libdns162 (= 1:9.10.3.dfsg.P4-10.1ubuntu4) but 1:9.10.3.dfsg.P4-10.1ubuntu1.4 is installed
 dnsutils : Depends: libdns162 (= 1:9.10.3.dfsg.P4-10.1ubuntu4) but 1:9.10.3.dfsg.P4-10.1ubuntu1.4 is installed
 gnome-software : Depends: gnome-software-common (= 3.22.7-0ubuntu3) but 3.20.1+git20170208.0.a34b091-0ubuntu1 is installed
 gvfs : Depends: gvfs-daemons (>= 1.30.4-0ubuntu1)
 gvfs-backends : Depends: gvfs-daemons (= 1.30.4-0ubuntu1)
 gvfs-daemons : Depends: gvfs-libs (= 1.28.2-1ubuntu2) but 1.30.4-0ubuntu1 is installed
                Depends: gvfs-common (= 1.28.2-1ubuntu2) but 1.30.4-0ubuntu1 is installed
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

Then I went to http://packages.ubuntu.com/ and in the 'search' para entered the names following 'Depends: ' and selected 'zesty'. Then I downloaded the .deb files for my hardware.

Next, I moved all the .deb files to /var/cache/apt/archives:

sudo mv *.deb /var/cache/apt/archives

Lastly I did:

sudo apt --fix-broken install

which executed without errors

HTH

  • The command autoremove not found. But now I cannot use apt-get to install it. – Kin Apr 16 '17 at 16:24
0
  • Option 1: Look for the this foreign click package:

    sudo updatedb
    locate -ir python.*click
    

    Then delete it manually, add the output to the question if you are in doubt.

  • Option 2: If you are still at that state mentioned in th e question:

    Preparing to unpack .../click-apparmor_0.3.18_amd64.deb ...
    Cannot start click due to a conflict with a different 
      locally-installed Python 'click' package.  Remove it 
      using Python packaging tools and try again.
    dpkg: warning: subprocess old pre-removal script returned error exit status 1
    
    1. Remove the installed package

      cd /var/lib/dpkg/info/
      sudo mv click-apparmor:amd64.prerm click-apparmor:amd64.prerm.backup
      sudo dpkg --force-depends -r  click-apparmor
      
    2. Try install the new package using:

      sudo apt -f install
      

      Add the new error if any to the question.

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.