Certbot broke suddenly, says No module named 'six'

My domain is: www.azomtech.com

I ran this command: sudo certbot delete

It produced this output:

dev1n@azompr1:/var/www$ sudo certbot delete
Traceback (most recent call last):
  File "/usr/bin/certbot", line 33, in <module>
    sys.exit(load_entry_point('certbot==1.8.0', 'console_scripts', 'certbot')())
  File "/usr/bin/certbot", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 2, in <module>
    from certbot._internal import main as internal_main
  File "/usr/lib/python3/dist-packages/certbot/_internal/main.py", line 9, in <module>
    import configobj
  File "/usr/lib/python3/dist-packages/configobj.py", line 22, in <module>
    import six
ModuleNotFoundError: No module named 'six'

My web server is (include version):

The operating system my web server runs on is (include version): Linux Debian: 5.6.0-2-amd64

My hosting provider, if applicable, is: Namecheap

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): same error above, but this might be useful

dev1n@azompr1:~$ apt-cache policy certbot | grep -i Installed
  Installed: 1.7.0-1

Certbot was installed correctly and works just fine in generating SSL certificates for the hosted websites.

But after hosting a new website (flask app with Gunicorn), certbot commands started throwing the error "ModuleNotFoundError: No module named 'six'".
Please help debug and fix the issue

1 Like

What version of Debian are you using? I'm currently not seeing any certbot-1.7.0 in the Debian repository: Debian Bullseye and Sid have 1.8.0.

I guess python3-six should have been pulled in as a dependency somehow for certbot, but perhaps it didn't.. Or it needs to be updated? You could try to (re)install that package.

1 Like

Its this:

dev1n@azompr1:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux bullseye/sid
Release:        oldstable-updates
Codename:       sid

I tried as you said but later got the same certbot error:

dev1n@azompr1:~$ sudo apt-get install python3-six
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-six is already the newest version (1.15.0-1).
python3-six set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 366 not upgraded.

yes I believe something broke after installing python packages but I'm not sure what, and I'm not very experienced with linux.. I just wanted to host a new app and then certbot stopped working

1 Like

Like Osiris suggested, I think re-installing might help:

sudo apt update && sudo apt install --reinstall python3-certbot python3-six
1 Like

Good, now the error changed:

dev1n@azompr1:~$ certbot --version
Traceback (most recent call last):
  File "/usr/bin/certbot", line 33, in <module>
    sys.exit(load_entry_point('certbot==1.8.0', 'console_scripts', 'certbot')())
  File "/usr/bin/certbot", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.8/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 2, in <module>
    from certbot._internal import main as internal_main
  File "/usr/lib/python3/dist-packages/certbot/_internal/main.py", line 16, in <module>
    from certbot import crypto_util
  File "/usr/lib/python3/dist-packages/certbot/crypto_util.py", line 30, in <module>
    from certbot import util
  File "/usr/lib/python3/dist-packages/certbot/util.py", line 23, in <module>
    from certbot._internal import constants
  File "/usr/lib/python3/dist-packages/certbot/_internal/constants.py", line 6, in <module>
    from acme import challenges
  File "/usr/lib/python3/dist-packages/acme/challenges.py", line 11, in <module>
    import requests
ModuleNotFoundError: No module named 'requests'

what do you suggest?

1 Like

Geez, somebody really did a number on your Python packages.

If I were you I'd probably blow the entire OS away and start again, but I guess you could try reinstall all of the transitive Python dependencies:

apt install --reinstall python3-acme python3-certifi python3-chardet python3-configargparse python3-configobj python3-cryptography python3-distro python3-future python3-idna python3-josepy python3-lib2to3 python3-minimal python3-openssl python3-parsedatetime python3-pkg-resources python3-requests python3-requests-toolbelt python3-rfc3339 python3-six python3-tz python3-urllib3 python3-zope.component python3-zope.event python3-zope.hookable python3-zope.interface
4 Likes

are you sure of this? :sweat_smile:
this is a productions server which makes me worried.

It's safe to run it with sudo?

1 Like

Thank you @_az, this worked with sudo!!
now certbot works fine

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.