Ubuntu – Broken package click on Ubuntu 16.10

16.10aptclick-packagespython3

When I run /usr/bin/click, I get the following error:

Traceback (most recent call last):
  File "/usr/bin/click", line 37, in <module>
    import click
ImportError: No module named 'click'

I tried to reinstall package click, but I got the same error during installation:

Reading package lists... Done
Building dependency tree       
Reading state information... Done
0 upgraded, 0 newly installed, 1 reinstalled, 0 to remove and 0 not upgraded.
Need to get 0 B/14,7 kB of archives.
After this operation, 0 B of additional disk space will be used.
(Reading database ... 255715 files and directories currently installed.)
Preparing to unpack .../click_0.4.45.1+16.10.20160916-0ubuntu1_amd64.deb ...
Unpacking click (0.4.45.1+16.10.20160916-0ubuntu1) over (0.4.45.1+16.10.20160916-0ubuntu1) ...
Processing triggers for ureadahead (0.100.0-19) ...
Setting up click (0.4.45.1+16.10.20160916-0ubuntu1) ...
Traceback (most recent call last):
  File "/usr/bin/click", line 37, in <module>
    import click
ImportError: No module named 'click'
dpkg: error processing package click (--configure):
 subprocess installed post-installation script returned error exit status 1
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for shared-mime-info (1.7-1) ...
Errors were encountered while processing:
 click
E: Sub-process /usr/bin/dpkg returned an error code (1)

I have already removed another package click, which comes from pip3, but it didn't help. It seems that either required files (I believe that their source is here) are absent on the system or python cannot find it.

So the questions are: where python package click should be located, and how can I fix the error.

Best Answer

Finally I have found the solution! In my case python module click came from aptitude package python3-click-package. However, it has been overwritten by another module click. After I removed the latter module, python3-click-package was left broken, so I simply reinstalled it, so that click works now:

sudo apt install --reinstall python3-click-package
Related Question