Can't renew certs. Import Error: cannot import name 'constants' from 'certbot'

My domain is:

cb.virtualairwaves.com

I ran this command:

sudo certbot renew --dry-run

It produced this output:

[famserve@ip-10-1-10-10 nginx]$ sudo certbot renew --dry-run
An unexpected error occurred:
ImportError: cannot import name 'constants' from 'certbot' (/usr/local/lib/python3.7/site-packages/certbot/__init__.py) Please see the logfile '/tmp/tmpo4nofxpy/log' for more details.
[famserve@ip-10-1-10-10 nginx]$

My web server is (include version):

ningx 1.16.1

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

Linux ip-10-1-10-10.us-west-1.compute.internal 3.10.0-957.27.2.el7.x86_64 #1 SMP Mon Jul 29 17:46:05 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
[famserve@ip-10-1-10-10 nginx]$

My hosting provider, if applicable, is:

AWS

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

[famserve@ip-10-1-10-10 nginx]$ certbot --version
An unexpected error occurred:
ImportError: cannot import name 'constants' from 'certbot' (/usr/local/lib/python3.7/site-packages/certbot/__init__.py) Please see the logfile '/tmp/tmpa6raox6v/log' for more details.
[famserve@ip-10-1-10-10 nginx]$

I tried sudo yum uninstall certbot python2-certbot-dns-route53 python2-certbot-nginx and reinstalling them.

This worked previously. Something changed with Python’s environment and I don’t know how to make certbot happy again. Uninstalling and reinstalling didn’t help.

1 Like

Installed a fresh enviornment in a virtualenv and got it to work. We’re rebuilding our servers from wholecloth via salt because the python got wonked somehow.

  475  pip install virtualenv
  476  sudo pip install virtualenv
  477  sudo virtualenv route53
  478  source route53/bin/activate
  479  sudo pip install certbot_dns_route53==$((certbot --version) 2>&1 | grep -oE "\b([0-9]{1,3}\.){2}[0-9]{1,3}\b")
  480  sudo certbot certonly -d "virtualairwaves.com" -d "*.virtualairwaves.com" --dns-route53 -m "robert@virtualairwaves.com" --server https://acme-v02.api.letsencrypt.org/directory --dry-run
  481  sudo certbot certonly -d "virtualairwaves.com" -d "*.virtualairwaves.com" --dns-route53 -m "robert@virtualairwaves.com" --server https://acme-v02.api.letsencrypt.org/directory
2 Likes

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