几个月前,我设置了一台新服务器,运行 Ubuntu 18.04 LTS。我成功安装了 certbot 并使用 cloudflare DNS 插件创建了我的证书。
现在到了续订的时候了,但是当我运行certbot renew
(或其他各种 certbot 命令)时,出现以下错误
# certbot renew
/usr/local/lib/python2.7/dist-packages/cryptography/__init__.py:39: CryptographyDeprecationWarning: Python 2 is no longer supported by the Python core team. Support for it is now deprecated in cryptography, and will be removed in a future release.
CryptographyDeprecationWarning,
Traceback (most recent call last):
File "/usr/local/bin/certbot", line 7, in <module>
from certbot.main import main
File "/usr/local/lib/python2.7/dist-packages/certbot/main.py", line 2, in <module>
from certbot._internal import main as internal_main
File "/usr/local/lib/python2.7/dist-packages/certbot/_internal/main.py", line 21, in <module>
from certbot._internal import cert_manager
File "/usr/local/lib/python2.7/dist-packages/certbot/_internal/cert_manager.py", line 16, in <module>
from certbot._internal import storage
File "/usr/local/lib/python2.7/dist-packages/certbot/_internal/storage.py", line 79, in <module>
def add_time_interval(base_time, interval, textparser=parsedatetime.Calendar()):
File "/usr/local/lib/python2.7/dist-packages/parsedatetime/__init__.py", line 270, in __init__
self.ptc = Constants()
File "/usr/local/lib/python2.7/dist-packages/parsedatetime/__init__.py", line 2381, in __init__
self.locale = get_icu(self.localeID)
File "/usr/local/lib/python2.7/dist-packages/parsedatetime/pdt_locales/icu.py", line 56, in get_icu
result['icu'] = icu = pyicu.Locale(locale)
AttributeError: 'module' object has no attribute 'Locale'
的输出locale -a
是
# locale -a
C
C.UTF-8
en_US.utf8
POSIX
我也跑过,pip install cryptography --upgrade
但没有什么改变。
我不确定是什么改变了它,导致它损坏了,而且我不知道如何让它工作!
答案1
检查以确保您没有 /usr/local/bin/certbot 脚本
我有一个,我想我曾经在这个系统上克隆过 certbot auto 包。删除它并重新运行 /usr/bin/certbot 后,我不再收到此错误。
另外,certbot 似乎是一个 python 3 应用程序,正确的 certbot 脚本启动如下:
#!/usr/bin/python3
# EASY-INSTALL-ENTRY-SCRIPT: 'certbot==0.31.0','console_scripts','certbot'
__requires__ = 'certbot==0.31.0'
import re
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(
load_entry_point('certbot==0.31.0', 'console_scripts', 'certbot')()
)
答案2
我通过切换到 python 3 解决了这个问题。