5

I am setting up my website to use https via certbot.

I am following the directions here

I run the wget and chmod with no problems, but when I execute:

./certbot-auto

I get the following errors:

Setting up gyp (0.1+20150913git1f374df9-1ubuntu1) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package gyp (--configure):
subprocess installed post-installation script returned error exit status 1
Setting up python-virtualenv (15.0.1+ds-3) ...
Traceback (most recent call last):
File "/usr/bin/pycompile", line 35, in
from debpython.version import SUPPORTED, debsorted, vrepr, \
File "/usr/share/python/debpython/version.py", line 24, in
from ConfigParser import SafeConfigParser
ImportError: No module named 'ConfigParser'
dpkg: error processing package python-virtualenv (--configure):
subprocess installed post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of node-gyp:
node-gyp depends on gyp (>= 0.1+20150913git1f374df9); however:
Package gyp is not configured yet.

dpkg: error processing package node-gyp (--configure):
dependency problems - leaving unconfigured
dpkg: dependency problems prevent configuration of npm:
npm depends on node-gyp (>= 0.10.9); however:
Package node-gyp is not configured yet.

dpkg: error processing package npm (--configure):
dependency problems - leaving unconfigured
Setting up trash-cli (0.12.9.14-2) ...

I have mostly been focusing on the error:

ImportError: No module named 'ConfigParser'

But can't find any solutions.

How do I fix this error?

p.s. I was wondering if this has something to do with different default python setups but ived tried both 2.7 and 3.5 to no avail, using ln -sf /usr/bin/python2.7 /usr/local/bin/python.

john-jones
  • 75
  • 13
  • [Possibly related?](http://stackoverflow.com/questions/14087598/python-3-importerror-no-module-named-configparser) – glibdud Oct 19 '16 at 20:57
  • It is, but the first answer doesnt really help me on how to solve the problem as it doesnt show me how to. and the second answer gives me that very error again. – john-jones Oct 19 '16 at 21:03
  • Check if build-essentials is installed. From my experience, node-gyp issues indicate some dependency not being installed. – jmreicha Oct 20 '16 at 04:12
  • I get the exact same error when i try to install build-essentials – john-jones Oct 20 '16 at 09:24
  • After linking to python2.7, did you try to reinstall configparser (pip install configparser)? Maybe have a look at that: [techglimpse.com/fix-no-module-named-import-error/](https://techglimpse.com/fix-no-module-named-import-error/) – JosefScript Oct 27 '16 at 17:03
  • After linking to 2.7, I do: pip install configparser. And then I get: Requirement already satisfied (use --upgrade to upgrade): configparser in /usr/local/lib/python3.5/dist-packages. Its like its installing the configparser in python 3.5 when i need to it install it in python 2.7. Do you know how to install configparse in 2.7? – john-jones Oct 27 '16 at 17:15

3 Answers3

4

First of all, removing Python 3 as suggested in a previous answer is a terrible idea, while it has a slight chance of fixing your particular problem, it is much more likely to create many more since any program depending on it will crash.

Second, your problem stems from a modification that was made to your system that should never have been made. python is meant to link to python2 by default (see PEP 394) for backwards compatibility and is provided by python-minimal on Ubuntu (see file list).

I would suggest removing broken packages, reinstalling python, python-minimal, python3 and python3-minimal running something along the lines of:

sudo apt update     # Get an up-to-date list of available packages
sudo apt autoclean  # Remove partial packages
sudo apt clean      # Remove package cache to force redownload
sudo apt install --reinstall python python-minimal python3 python3-minimal

Should any of the broken packages refuse to be removed through apt, you can use sudo dpkg --remove -force --force-remove-reinstreq $BROKEN_PACKAGE_NAMES (where you should of course replace the variable with the actual broken packages). BEWARE, this will pretty much uninstall anything so do not attempt to uninstall a package you believe to be critical to your system.

Once you've fixed your system Python, run certbot-auto again.

Ginnungagap
  • 1,998
  • 8
  • 9
  • all works until i reach sudo apt install --reinstall python python-minimal python3 python3-minimal then i get several errors, the first is: Preparing to unpack .../mozo_1.14.1-1+sarah_all.deb ... File "/usr/bin/pyclean", line 63 except (IOError, OSError), e: – john-jones Nov 02 '16 at 18:16
  • But now running the certbot seems to almost work. I get error: E: Sub-process /usr/bin/dpkg returned an error code (1) – john-jones Nov 02 '16 at 18:20
  • Can you try a `sudo apt install -f` to see what `apt` and `dpkg` consider broken? – Ginnungagap Nov 02 '16 at 19:42
1

ConfigParser is a buildin module, but it was changed to lowercase configparser with python 3. You are running a python2 script with python3.

Getting rid of python3 and installing only python2 should solve your problem. I use personally use dehydrated which might also be an option.

user189695
  • 89
  • 5
  • Is it not dangerous to do so? How is it best to go about only removing python 3.5? – john-jones Oct 31 '16 at 19:47
  • When you uninstall python3 apt should state which programs it also removes, if you want to keep any of those you need to find an other solution. – user189695 Nov 05 '16 at 11:51
  • Also note debian has packaged certbot. You could do a `apt-get install certbot` and you have the tool you need. This software version is properly tested and patched by the debian community. This is the way i would recommend. – user189695 Nov 05 '16 at 11:53
0

The same problem happened when I was trying to install nodejs and npm with "sudo apt-get install -f nodejs npm". Just modify the default python version. "sudo rm -rf /usr/bin/python" "sudo ln -s /usr/bin/python2 /usr/bin/python" will be ok.