No module named datetime Error when Autorenew certbot

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:

I ran this command:
./certbot-auto renew

It produced this output:

Error: couldn’t get currently installed version for /opt/
Traceback (most recent call last):
File “/opt/”, line 7, in
from certbot.main import main
File “/opt/”, line 9, in
from acme import jose
File “/opt/”, line 37, in
from acme.jose.interfaces import JSONDeSerializable
File “/opt/”, line 9, in
from acme.jose import util
File “/opt/”, line 5, in
import OpenSSL
File “/opt/”, line 8, in
from OpenSSL import rand, crypto, SSL
File “/opt/”, line 1, in
import datetime
ImportError: No module named datetime

Then I ran:
python -c 'import datetime; print'

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

Any help greatly appreciated!!!


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


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 (
openssl is already the newest version (
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/") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen(’/etc/letsencrypt/live/’,‘r’) error:2006D080:BIO routines:BIO_new_file:no such file)

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

1 Like

Just checking the folder has…

It has only:


My .bak of that has:

accounts archive csr keys live renewal

./certbot-auto certificates


No certs found.

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:

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