Python cryptography module not found after certbot install

Please fill out the fields below so we can help you better. Note: you must provide your domain name to get help. Domain names for issued certificates are all made public in Certificate Transparency logs (e.g. https://crt.sh/?q=example.com), so withholding your domain name here does not increase secrecy, but only makes it harder for us to provide help.

My domain is: bfinationalarchivemedia.bfi.org.uk

I ran this command: sudo certbot --nginx -d bfinationalarchivemedia.bfi.org.uk -d www.bfinationalarchivemedia.bfi.org.uk

It produced this output:
Traceback (most recent call last):
File "/usr/bin/certbot", line 11, in
load_entry_point('certbot==0.40.0', 'console_scripts', 'certbot')()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 490, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2854, in load_entry_point
return ep.load()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2445, in load
return self.resolve()
File "/usr/lib/python3/dist-packages/pkg_resources/init.py", line 2451, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python3/dist-packages/certbot/main.py", line 10, in
import josepy as jose
File "/usr/lib/python3/dist-packages/josepy/init.py", line 41, in
from josepy.interfaces import JSONDeSerializable
File "/usr/lib/python3/dist-packages/josepy/interfaces.py", line 7, in
from josepy import errors, util
File "/usr/lib/python3/dist-packages/josepy/util.py", line 7, in
import OpenSSL
File "/usr/lib/python3/dist-packages/OpenSSL/init.py", line 8, in
from OpenSSL import crypto, SSL
File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 12, in
from cryptography import x509
ModuleNotFoundError: No module named 'cryptography'

My web server is (include version):
nginx version: nginx/1.18.0 (Ubuntu)
built with OpenSSL 1.1.1f 31 Mar 2020

The operating system my web server runs on is (include version): Ubuntu LTS 20.04

My hosting provider, if applicable, is: n/a

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): certbot 0.40.0

This is strange. And it sounds like it's an Ubuntu problem, not a certbot one.

Install certbot following the instructions on certbot.eff.org, please.

2 Likes

I removed certbot via apt, and reinstalled using snap, and that fixed the issue - thank you!

I'm now getting a failure of the challenge, but I'll troubleshoot that and raise a separate issue if necessary.

5 Likes

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