17

How to get removed broken package click? I'm trying install ubuntu-sdk in my 14.04 Ubuntu. I am getting too many errors.

sudo apt-get autoremove -f click
Reading package lists ... Done
Building dependency tree
Is read status information ... Done
The following packages will be REMOVED:
   click
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation released 166 ks of disk space.
Do you want to continue? [Y/n] y
(Reading database ... 350824 files and directories currently installed.)
Removing click (0.4.38.5-0~457~ ubuntu14.04.1) ...
Trace Back (most recent call last):
   File "/usr/bin/click", line 31, in <module>
     from click import commands
Import Error: can not import name 'commands'
dpkg: error processing package click (--remove):
  subprocess command file pre-removal installed returned error exit status 1
Reading was too many errors:
  click
E: Sub-process /usr/bin/dpkg Returned an error code (1)

If im trying command sudo apt-get purge -f

Same errors happened.

0

6 Answers 6

30

After that was not successful, I have tested this "the hard way" ... and ... it works!

sudo rm /usr/bin/click
sudo apt-get autoremove -f click

The file has a problem when importing a Python module and you want to remove the package anyway. Therefore the file can be removed manually.

3
  • 2
    @A.B. Pretty bad advice since second command deletes a lot of system packages Oct 23, 2016 at 14:13
  • This actually worked for me in Ubuntu 18.04 LTS. However, I used sudo apt-get --fix-broken install after the two commands.
    – afagarap
    May 30, 2018 at 18:33
  • Thanks a lot!! I had been trying to sort this out for 3 days!!
    – Trect
    Jun 13, 2018 at 2:20
11

i've had same error with broken packages click and click-apparmor, url-dispatcher after upgrading 14.04 -> 14.10 -> 15.04

*updated:

the solution for me was removing package folder rm -rv /usr/local/lib/python3.4/dist-packages/click and then:

sudo apt-get update && sudo apt-get install -f

solution source

2
  • 1
    When you write "removing the package /usr/local/lib/python3.4/dist-packages/click", do you mean removing the file /usr/local/lib/python3.4/dist-packages/click or removing the package click May 2, 2015 at 1:30
  • 2
    removing whole folder manually : rm -rv /usr/local/lib/python3.4/dist-packages/click , because nothing of apt-get -f install or dpkg --reconfigure -a , apt-get autoremove -f click , apt-get purge click works. May 2, 2015 at 6:58
6
sudo apt-get remove click
sudo pip3 uninstall click
sudo pip uninstall click
sudo apt-get install click -f

The problem is that many upgrade users will have a version of click installed with a version number under their pip or pip3 repository, these aren't managed by apt, and they take priority when Python's import keyword is invoked.

So, you need to uninstall them before reinstalling click is going to do you any good. The reasons they might be installed is that it can happen during setup of a third-party python app, and God knows I've done a few.

1
  • 1
    I'm just a reviewer: could you copy-paste all of the above in your actual answer before the system decides to delete your answer because of a lack of quality? ;-)
    – Fabby
    Jan 20, 2016 at 16:24
3

Install click again to install the dependencies.

sudo apt-get install --reinstall click

Then remove it with this command.

sudo apt-get autoremove -f click

If that does not work, then install python and/or python3:

sudo apt-get install --reinstall python
sudo apt-get install --reinstall python3
sudo apt-get install --reinstall python3-click

and than again

sudo apt-get autoremove -f click
4
  • Nothing help, im get a same errors.
    – lahtis
    Apr 26, 2015 at 19:32
  • Answer updated.
    – A.B.
    Apr 27, 2015 at 7:25
  • 1
    Try this three commands: sudo apt-get install --reinstall python; sudo apt-get install --reinstall python3; sudo apt-get install --reinstall python3-click and again sudo apt-get autoremove -f click
    – A.B.
    Apr 27, 2015 at 7:28
  • Nothing help.Traceback (most recent call last): File "/usr/bin/click", line 31, in <module> from click import commands ImportError: cannot import name 'commands' dpkg: error processing package click (--remove):
    – lahtis
    Apr 27, 2015 at 19:47
0

You can try:

sudo dpkg --force-all -P click  

or:

sudo dpkg --force-all -r click
1
  • 1
    Package is totally broken, cannot install or unistall package.
    – lahtis
    Apr 27, 2015 at 19:44
0

In my case it was because I also had a python3 version of click installed through pip3. When I uninstalled the python3 version everything worked fine.

You must log in to answer this question.

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