ubuntu 16.04执行letsencrypt的时候报告错误“ImportError: No module named datetime”

网站一直使用letsencrypt提供的HTTPS证书,这个证书的问题在于每隔三个月就必须更新一次,本次更新证书的时候,提示如下错误:

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 9, 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

错误发生的原因在于letsencrypt自己构建了一个Python的虚拟环境来隔离,但是早期建立的虚拟环境中是缺少部分软件包的,而自身的BUG导致也没有重新更新虚拟环境,导致出现异常。

解决方法就是删除letsencrypt自己构建的Python的虚拟环境,然后继续执行脚本让他重建即可。

$ rm -rf ~/.local/share/letsencrypt

参考链接


发布者

《ubuntu 16.04执行letsencrypt的时候报告错误“ImportError: No module named datetime”》上有1条评论

回复 丁远杭 取消回复

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