No module named datetime Error when Autorenew certbot


#1

Hi Let’s Encrypt community, I need some help with auto-renewing my SSL :slight_smile:
It’s been auto-renewing manually every 90 days for a while but after a server tidy up it seems to be showing some errors now and I can’t debug.

My domain is:
https://rwwriter.com

I ran this command:
./certbot-auto renew

It produced this output:

Error: couldn’t get currently installed version for /opt/eff.org/certbot/venv/bin/letsencrypt:
Traceback (most recent call last):
File “/opt/eff.org/certbot/venv/bin/letsencrypt”, line 7, in
from certbot.main import main
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py”, line 9, in
from acme import jose
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/acme/jose/init.py”, line 37, in
from acme.jose.interfaces import JSONDeSerializable
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/acme/jose/interfaces.py”, line 9, in
from acme.jose import util
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/acme/jose/util.py”, line 5, in
import OpenSSL
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/OpenSSL/init.py”, line 8, in
from OpenSSL import rand, crypto, SSL
File “/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/OpenSSL/crypto.py”, line 1, in
import datetime
ImportError: No module named datetime

Then I ran:
python -c 'import datetime; print datetime.datetime.now()'

And it prints the date:

2017-12-29 20:59:01.267586

So it’s not a Python thing…

So I tried this:

I moved the let’s encrypt folder to let’sencrypt.bak and ran AUTORENEW again and same error…

My web server is (include version):
Ubuntu 16.04.3 LTS

My hosting provider, if applicable, is:

I can login to a root shell on my machine (yes or no, or I don’t know):
Yes


Any help greatly appreciated!!!

Cheers


#2

What happens if you rename or delete the /opt/eff.org/certbot/ directory and run ./certbot-auto renew again? It should make certbot-auto reinstall itself and could fix this.


#3

Thanks @mnordhoff - appreciate that

It ran and outputted this:

Reading package lists… Done
Reading package lists… Done
Building dependency tree
Reading state information… Done
gcc is already the newest version (4:5.3.1-1ubuntu1).
libffi-dev is already the newest version (3.2.1-4).
python is already the newest version (2.7.11-1).
python-dev is already the newest version (2.7.11-1).
augeas-lenses is already the newest version (1.4.0-0ubuntu1.1).
ca-certificates is already the newest version (20170717~16.04.1).
libaugeas0 is already the newest version (1.4.0-0ubuntu1.1).
python-virtualenv is already the newest version (15.0.1+ds-3ubuntu1).
virtualenv is already the newest version (15.0.1+ds-3ubuntu1).
virtualenv set to manually installed.
libssl-dev is already the newest version (1.1.0g-2.1+ubuntu16.04.1+deb.sury.org+1).
openssl is already the newest version (1.1.0g-2.1+ubuntu16.04.1+deb.sury.org+1).
The following packages were automatically installed and are no longer required:
dh-php libexporter-tiny-perl liblist-moreutils-perl libonig2 libpcre32-3
libpcrecpp0 libqdbm14 libzip4 pkg-php-tools xml2
Use ‘sudo apt autoremove’ to remove them.
0 upgraded, 0 newly installed, 0 to remove and 5 not upgraded.
Creating virtual environment…
Installing Python packages…
Installation succeeded.
Saving debug log to /var/log/letsencrypt/letsencrypt.log


No renewals were attempted.


I tried a server restart and it fails.

Nginx debugger shows:

BIO_new_file("/etc/letsencrypt/live/rwwriter.com/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/etc/letsencrypt/live/rwwriter.com/fullchain.pem’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file)


#4

What does “./certbot-auto certificates” show?


#5

Just checking the folder has…

It has only:

renewal-hooks


My .bak of that has:

accounts archive csr keys live renewal

So
./certbot-auto certificates

shows:


No certs found.


#6

I moved the certs back into letsencrypt folder and re-ran the command and boom :slight_smile:
Thanks @mnordhoff

Now to sort out the CRON :wink:


#7

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