certbot renew: ImportError: cannot import name constants

certbot renew
An unexpected error occurred:
ImportError: cannot import name constants
Please see the logfile ‘/tmp/tmpl4isIP/log’ for more details.

Installing snapd

With the EPEL repository added to your CentOS installation, simply install the snapd package:

$ sudo yum install snapd

Once installed, the systemd unit that manages the main snap communication socket needs to be enabled:

$ sudo systemctl enable --now snapd.socket

To enable classic snap support, enter the following to create a symbolic link between /var/lib/snapd/snap and /snap:

$ sudo ln -s /var/lib/snapd/snap /snap

Remove certbot-auto and any Certbot OS packages

If you have any Certbot packages installed using an OS package manager like apt, dnf, or yum, you should remove them before installing the Certbot snap to ensure that when you run the command certbot the snap is used rather than the installation from your OS package manager. The exact command to do this depends on your OS, but common examples are sudo apt-get remove certbot, 

sudo dnf remove certbot, or sudo yum remove certbot.

If you previously used Certbot through the certbot-auto script, you should also remove its installation by following the instructions here.

Install CertbotRun this command on the command line on the machine to install Certbot.

sudo snap install --classic certbot

Prepare the Certbot commandExecute the following instruction on the command line on the machine to ensure that the certbot command can be run.sudo

ln -s /snap/bin/certbot /usr/bin/certbot

Choose how you’d like to run Certbot

Either get and install your certificates…Run this command to get a certificate and have Certbot edit your Nginx configuration automatically to serve it, turning on HTTPS access in a single step.

sudo certbot --nginx

Or, just get a certificateIf you’re feeling more conservative and would like to make the changes to your Nginx configuration by hand, run this command.

sudo certbot certonly --nginx

Test automatic renewalThe Certbot packages on your system come with a cron job or systemd timer that will renew your certificates automatically before they expire. You will not need to run Certbot again, unless you change your configuration. You can test automatic renewal for your certificates by running this command:

sudo certbot renew --dry-run

The command to renew certbot is installed in one of the following locations:

  • /etc/crontab/
  • /etc/cron.*/*
  • systemctl list-timers


您的电子邮箱地址不会被公开。 必填项已用*标注