腾讯云Ubuntu Server 16.04.7 LTS升级系统到Ubuntu Server 18.04.5 LTS之后letsencrypt证书更新出现异常“ImportError: cannot import name _remove_dead_weakref”

腾讯云`Ubuntu Server 16.04.7 LTS`升级系统到`Ubuntu Server 18.04.5 LTS`之后,`letsencrypt`证书更新出现异常,如下:

$ sudo ./letsencrypt-auto
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 <module>
    from certbot.main import main
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 2, in <module>
    from certbot._internal import main as internal_main
  File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/_internal/main.py", line 6, in <module>
    import logging.handlers
  File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
    import sys, os, time, cStringIO, traceback, warnings, weakref, collections
  File "/usr/lib/python2.7/weakref.py", line 14, in <module>
    from _weakref import (
ImportError: cannot import name _remove_dead_weakref

原因为系统版本变化过大导致以前安装的`Python`组件不能适应最新的系统,最简单的方法就是删除之前安装的`Python`组件,让`letsencrypt`重新安装即可。

$ sudo apt-get install python-pip

$ sudo rm -rf /opt/eff.org/

$ sudo ./letsencrypt-auto

参考链接


Cannot renew certificate “ImportError: cannot import name _remove_dead_weakref”

发布者

发表回复

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