Certbot error with executing

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. crt.sh | 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: raulsammer.com

I ran this command: certbot --nginx -d raulsammer.com -d www.raulsammer.com

It produced this output: An unexpected error occurred:
ImportError: cannot import name 'constants' from 'certbot' (/usr/local/lib/python3.7/dist-packages/certbot/init.py)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/tmpf__ens2y/log or re-run Certbot with -v for more details.

My web server is (include version): nginx last version

The operating system my web server runs on is (include version): debian 10

My hosting provider, if applicable, is: GCP, virtual machine

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

root@hydra-maquinas:/etc/nginx/sites-available# certbot --version
An unexpected error occurred:
ImportError: cannot import name 'constants' from 'certbot' (/usr/local/lib/python3.7/dist-packages/certbot/init.py)
Ask for help or search for solutions at https://community.letsencrypt.org. See the logfile /tmp/tmp19fd25u1/log or re-run Certbot with -v for more details.

Looks to me you've installed Certbot using pip system wide, correct?

3 Likes

yes, how this tutorial: How To Secure Nginx with Let's Encrypt on Debian 10 | DigitalOcean

That guide doesn't use pip. That guide uses apt, but as you can see here:

https://packages.debian.org/buster/all/python3-certbot/filelist

..the Debian package for certbot (which pulls in this python3-certbot package) does not put its files in /usr/local/lib/ as in your output.

So it seems you're not running the Certbot installed by apt, but by something else, maybe pip.

2 Likes

@raulsammer You are probably better off following Certbot's install instructions rather than a 3Y old guide. See below for Debian 10 with nginx instructions:

4 Likes

I just uninstalled certbot from pip and just uninstalled certbot from apt.

I am reinstalling certbot from apt.

But now when I run: certbot --nginx -d raulsammer.com -d www.raulsammer.com

I get this error:

Traceback (most recent call last):
File "/usr/bin/certbot", line 11, in
load_entry_point('certbot==0.31.0', 'console_scripts', 'certbot')()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py", line 486, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py", line 2867, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py", line 2471, in load
return self.resolve()
File "/usr/local/lib/python3.7/dist-packages/pkg_resources/init.py", line 2477, in resolve
module = import(self.module_name, fromlist=['name'], level=0)
File "/usr/lib/python3/dist-packages/certbot/main.py", line 18, in
from certbot import account
File "/usr/lib/python3/dist-packages/certbot/account.py", line 21, in
from certbot import constants
File "/usr/lib/python3/dist-packages/certbot/constants.py", line 53, in
tls_sni_01_port=challenges.TLSSNI01Response.PORT,
AttributeError: module 'acme.challenges' has no attribute 'TLSSNI01Response'

I concur with @MikeMcQ, don't use pip, don't use apt, use snap.

4 Likes

ok, then uninstall everything. And how do I install again certbot and cert bot plugin for nginx using snap.

 

4 Likes

work fine!

1 Like

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