Issues with Certbot after updating to Ubuntu 20.04

Ubuntu 20.04.

I am trying to simply renew my domains with this command:
certbot --nginx renew
However, I am getting this error when I run the command:

Traceback (most recent call last):
  File "/usr/local/bin/certbot", line 6, in <module>
from certbot.main import main
  File "/usr/local/lib/python3.6/dist-packages/certbot/", line 10, in <module>
import josepy as jose
  File "/usr/lib/python3/dist-packages/josepy/", line 41, in <module>
from josepy.interfaces import JSONDeSerializable
  File "/usr/lib/python3/dist-packages/josepy/", line 7, in <module>
from josepy import errors, util
  File "/usr/lib/python3/dist-packages/josepy/", line 7, in <module>
import OpenSSL
  File "/usr/local/lib/python3.6/dist-packages/OpenSSL/", line 8, in <module>
from OpenSSL import crypto, SSL
  File "/usr/local/lib/python3.6/dist-packages/OpenSSL/", line 12, in <module>
from cryptography import x509
  File "/usr/local/lib/python3.6/dist-packages/cryptography/x509/", line 8, in <module>
from cryptography.x509.base import (
  File "/usr/local/lib/python3.6/dist-packages/cryptography/x509/", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
  File "/usr/local/lib/python3.6/dist-packages/cryptography/x509/", line 13, in <module>
from asn1crypto.keys import PublicKeyInfo
ModuleNotFoundError: No module named 'asn1crypto'

I have tried to reinstall certbot and python but nothing has helped.

/usr/local/bin/certbot suggests that you have installed Certbot from pip. This is not a supported method of installation.

Remove the pip-installed Certbot installation and follow along the installation instructions for Ubuntu 20.04 from, which is to install Certbot either from snap or apt.

I installed via apt.

certbot is already the newest version (0.40.0-1).
python3-certbot-nginx is already the newest version (0.40.0-0ubuntu0.1).

You’ll want to remove the pip-installed one (/usr/local/bin/certbot) as well, as it is the one that is taking priority in your PATH.

The stuff that is installed from apt goes into /usr/bin/ and /usr/lib/, the conflicting pip binaries and libraries go into /usr/local/bin/ and /usr/local/lib/.

I think you might just be able to remove/disable the /usr/local/bin/certbot binary and everything will work.

If not, we’ll have to work through the individual library errors.

I’m having issues running pip, how can I manually change the path?

Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/", line 40, in <module>
    from pip._internal.cli.autocompletion import autocomplete
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/", line 8, in <module>
    from pip._internal.cli.main_parser import create_main_parser
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/", line 8, in <module>
    from pip._internal.cli import cmdoptions
  File "/usr/local/lib/python3.6/dist-packages/pip/_internal/cli/", line 14, in <module>
    from distutils.util import strtobool
ModuleNotFoundError: No module named 'distutils.util'

I have disutils installed, I rather just change the path and not figure this random python issue out.

I’m not sure why you need to run pip. But again, that is not a pip that you installed from apt. It’s broken for approximately the same reason that your Certbot is broken - stuff installed outside of apt gets screwed up by major OS upgrades.

If you run this, does it work?

/usr/bin/certbot renew --dry-run

If it does, then all you need to do is remove the other Certbot binary from your path.

I got this error when I ran the command:

An unexpected error occurred:
pkg_resources.DistributionNotFound: The 'asn1crypto>=0.21.0' distribution was not found and is required by cryptography
Please see the logfile '/tmp/tmpa5t141qk/log' for more details.

And the log file reads:

2020-07-27 23:12:36,785:DEBUG:certbot.log:Exiting abnormally:
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==0.40.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python3/dist-packages/certbot/", line 1348, in main
    plugins = plugins_disco.PluginsRegistry.find_all()
  File "/usr/lib/python3/dist-packages/certbot/plugins/", line 208, in find_all
    plugin_ep = PluginEntryPoint(entry_point)
  File "/usr/lib/python3/dist-packages/certbot/plugins/", line 50, in __init__
    self.plugin_cls = entry_point.load()
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/", line 2345, in load
    self.require(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/", line 2368, in require
    items = working_set.resolve(reqs, env, installer, extras=self.extras)
  File "/usr/local/lib/python3.6/dist-packages/pkg_resources/", line 784, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'asn1crypto>=0.21.0' distribution was not found and is required by cryptography

I guess that would happen if you had an outdated version of the cryptography library lying around in /usr/local/lib.

IDK. Maybe something like:

apt install --reinstall python3-cryptography

to try get the right version.

If I were you, I would try to install the Certbot snap. Might take a long time to fix these Python issues.

Tried reinstalling python3-crytography and it’s still giving me the error.

I have also tried to install via snap, but it seems to be using the old certbot.

Fixed the issue, I manually change the certbot file to use python 3.8, and it magically works now.

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