certbot setting up ssl, error "No module named 'ConfigParser'"

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.


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.


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.