# No module named datetime Error when Autorenew certbot

**URL:** <https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219>\
**Category:** Help\
**Created:** [December 30, 2017, 2:01am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219 "2017-12-30T02:01:48Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuzool](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/yuzool/32/18967_2.png) [@yuzool](https://community.letsencrypt.org/u/yuzool)\
**Post date:** [December 30, 2017, 2:01am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/1 "2017-12-30T02:01:48Z")

</div>

Hi Let's Encrypt community, I need some help with auto-renewing my SSL 🙂  
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](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:

> <https://github.com/certbot/certbot/issues/4776#issuecomment-306989544>
>
> \## My operating system is (include version):
> Ubuntu Xenial
> 
> \## I installed Ce…rtbot with (certbot-auto, OS package manager, pip, etc):
> certbot-auto
> 
> \## I ran this command and it produced this output:
> ./certbot-auto renew
> 
> \`\`\`Error: couldn't get currently installed version for /root/.local/share/letsencrypt/bin/letsencrypt: 
> Traceback (most recent call last):
> File "/root/.local/share/letsencrypt/bin/letsencrypt", line 7, in \<module\>
> from certbot.main import main
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/certbot/main.py", line 13, in \<module\>
> from acme import jose
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/\_\_init\_\_.py", line 37, in \<module\>
> from acme.jose.interfaces import JSONDeSerializable
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/interfaces.py", line 9, in \<module\>
> from acme.jose import util
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/acme/jose/util.py", line 4, in \<module\>
> from cryptography.hazmat.primitives.asymmetric import rsa
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/primitives/asymmetric/rsa.py", line 14, in \<module\>
> from cryptography.hazmat.backends.interfaces import RSABackend
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/cryptography/hazmat/backends/\_\_init\_\_.py", line 7, in \<module\>
> import pkg\_resources
> File "/root/.local/share/letsencrypt/local/lib/python2.7/site-packages/pkg\_resources/\_\_init\_\_.py", line 36, in \<module\>
> import plistlib
> File "/usr/lib/python2.7/plistlib.py", line 62, in \<module\>
> import datetime
> ImportError: No module named datetime
> \`\`\`

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

---

<div class="post-metadata">

**Author:** ![mnordhoff](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mnordhoff/32/22583_2.png) [@mnordhoff](https://community.letsencrypt.org/u/mnordhoff)\
**Post date:** [December 30, 2017, 2:34am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/2 "2017-12-30T02:34:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yuzool](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/yuzool/32/18967_2.png) [@yuzool](https://community.letsencrypt.org/u/yuzool)\
**Post date:** [December 30, 2017, 5:02am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/3 "2017-12-30T05:02:52Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![mnordhoff](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/mnordhoff/32/22583_2.png) [@mnordhoff](https://community.letsencrypt.org/u/mnordhoff)\
**Post date:** [December 30, 2017, 5:29am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/4 "2017-12-30T05:29:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yuzool](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/yuzool/32/18967_2.png) [@yuzool](https://community.letsencrypt.org/u/yuzool)\
**Post date:** [December 30, 2017, 5:29am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/5 "2017-12-30T05:29:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![yuzool](https://sea3.discourse-cdn.com/letsencrypt/user_avatar/community.letsencrypt.org/yuzool/32/18967_2.png) [@yuzool](https://community.letsencrypt.org/u/yuzool)\
**Post date:** [December 30, 2017, 6:06am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/6 "2017-12-30T06:06:22Z")

</div>

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

Now to sort out the CRON 😉

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/letsencrypt/original/3X/c/a/ca6c06ea1ea201324bba7048c6841ce60236468d.png) [@system](https://community.letsencrypt.org/u/system)\
**Post date:** [January 29, 2018, 6:06am UTC](https://community.letsencrypt.org/t/no-module-named-datetime-error-when-autorenew-certbot/49219/7 "2018-01-29T06:06:28Z")

</div>

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