Linux 中的 Certbot returns "No module named 'six'" 错误

Certbot returns "No module named 'six'" error in Linux

Certbot 已正确安装在 Debian 上(oldstable-updates),并且可以很好地为托管网站生成 SSL 证书。

但是在托管一个新网站(使用 Gunicorn 的 flask 应用程序)之后,certbot 命令开始抛出错误“ModuleNotFoundError:没有名为 'six' 的模块”。

dev1n@azompr1:~$ apt-cache policy certbot | grep -i Installed
  Installed: 1.7.0-1


dev1n@azompr1:~$ sudo certbot delete
Traceback (most recent call last):
  File "/usr/bin/certbot", line 11, in <module>
    load_entry_point('certbot==1.7.0', 'console_scripts', 'certbot')()
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 473, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 2843, in load_entry_point
    return ep.load()
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 2447, in load
    return self.resolve()
  File "/usr/local/lib/python3.8/dist-packages/pkg_resources/__init__.py", line 2453, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python3/dist-packages/certbot/main.py", line 2, in <module>
    from certbot._internal import main as internal_main
  File "/usr/lib/python3/dist-packages/certbot/_internal/main.py", line 9, in <module>
    import configobj
  File "/usr/lib/python3/dist-packages/configobj.py", line 22, in <module>
    import six
ModuleNotFoundError: No module named 'six'
dev1n@azompr1:~$

为什么它坏了,我该如何修复它?

在 LetsEncrypt 论坛的帮助下,我终于找到了解决方案。

首先我运行

sudo apt update && sudo apt install --reinstall python3-certbot python3-six

然后

sudo apt install --reinstall python3-acme python3-certifi python3-chardet python3-configargparse python3-configobj python3-cryptography python3-distro python3-future python3-idna python3-josepy python3-lib2to3 python3-minimal python3-openssl python3-parsedatetime python3-pkg-resources python3-requests python3-requests-toolbelt python3-rfc3339 python3-six python3-tz python3-urllib3 python3-zope.component python3-zope.event python3-zope.hookable python3-zope.interface

这将修复系统中损坏的 python;之后,certbot 工作得很好。