Certbot 因 AttributeError 失败:'module' 对象没有属性 'Locale'

Ben*_*ess 7 ubuntu python certbot

几个月前我设置了一个新服务器,运行 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'
Run Code Online (Sandbox Code Playgroud)

的输出locale -a

# locale -a
C
C.UTF-8
en_US.utf8
POSIX
Run Code Online (Sandbox Code Playgroud)

我也跑了,pip install cryptography --upgrade但这并没有改变任何东西。

我不确定是什么改变了它,我不知道如何让它工作!

小智 1

检查以确保您没有 /usr/local/bin/certbot 脚本

我有一个,我想我在这个系统上克隆了一次 certbot 自动软件包。删除它并返回运行 /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')()
    )
Run Code Online (Sandbox Code Playgroud)