5

我在 centos 上使用 nginx 7.3

我在https://certbot.eff.org/#centosrhel7-nginx之后安装了 certbot

运行时出现错误 certbot --nginx

[root@demo src]# certbot --nginx
Traceback (most recent call last):
  File "/usr/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.14.1', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 564, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2662, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2316, in load
    return self.resolve()
  File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 2322, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 14, in <module>
    from certbot import account
  File "/usr/lib/python2.7/site-packages/certbot/account.py", line 17, in <module>
    from acme import messages
  File "/usr/lib/python2.7/site-packages/acme/messages.py", line 4, in <module>
    from acme import challenges
  File "/usr/lib/python2.7/site-packages/acme/challenges.py", line 10, in <module>
    import requests
  File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 58, in <module>
    from . import utils
  File "/usr/lib/python2.7/site-packages/requests/utils.py", line 32, in <module>
    from .exceptions import InvalidURL
  File "/usr/lib/python2.7/site-packages/requests/exceptions.py", line 10, in <module>
    from .packages.urllib3.exceptions import HTTPError as BaseHTTPError
  File "/usr/lib/python2.7/site-packages/requests/packages/__init__.py", line 95, in load_module
    raise ImportError("No module named '%s'" % (name,))
ImportError: No module named 'requests.packages.urllib3'

包:

[root@demo src]# pip list
acme (0.14.1)
backports.ssl-match-hostname (3.4.0.2)
certbot (0.14.1)
certifi (2017.7.27.1)
cffi (1.6.0)
chardet (3.0.4)
Cheetah (2.4.4)
cloud-init (0.7.6)
ConfigArgParse (0.11.0)
configobj (4.7.2)
cryptography (1.3.1)
decorator (3.4.0)
enum34 (1.0.4)
future (0.16.0)
idna (2.6)
iniparse (0.4)
ipaddress (1.0.16)
IPy (0.75)
Jinja2 (2.9.6)
jsonpatch (1.16)
jsonpointer (1.10)
kitchen (1.1.1)
Markdown (2.6.8)
MarkupSafe (1.0)
mock (1.0.1)
ndg-httpsclient (0.3.2)
oauth (1.0.1)
parsedatetime (1.5)
perf (0.1)
pip (9.0.1)
ply (3.4)
policycoreutils-default-encoding (0.1)
prettytable (0.7.2)
psutil (2.2.1)
pyasn1 (0.1.9)
pycparser (2.14)
pycurl (7.19.0)
pygobject (3.14.0)
pygpgme (0.3)
pyliblzma (0.5.3)
pyOpenSSL (0.13.1)
pyparsing (1.5.6)
pyRFC3339 (1.0)
python2-pythondialog (3.3.0)
pytz (2012d)
pyudev (0.15)
pyxattr (0.5.1)
PyYAML (3.12)
requests (2.18.4)
seobject (0.1)
sepolicy (1.1)
setuptools (36.2.7)
six (1.9.0)
slip (0.4.0)
slip.dbus (0.4.0)
urlgrabber (3.10)
urllib3 (1.22)
yum-axelget (1.0.4)
yum-metadata-parser (1.1.4)
zope.component (4.1.0)
zope.event (4.0.3)
zope.interface (4.0.5)

我应该怎么办?

4

2 回答 2

5

试试看pip install --upgrade --force-reinstall 'requests==2.6.0' urllib3,我也遇到了同样的问题https://niuhp.com/other/https-certbot.html

于 2017-10-11T06:58:19.383 回答
0

这是因为 "python-urllib3.noarch" 安装失败:

$ sudo yum install python2-certbot-nginx

...
  Installing : python-urllib3-1.10.2-5.el7.noarch                                                                                                                                                     11/37 
Error unpacking rpm package python-urllib3-1.10.2-5.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
...

Installed:
  python2-certbot-nginx.noarch 0:0.27.1-1.el7                                                                                                                                                               

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.1-3.el7_5.1          certbot.noarch 0:0.27.1-1.el7
...

Failed:
  python-urllib3.noarch 0:1.10.2-5.el7

解决方案:

根据上面的错误信息,只需将该目录“ssl_match_hostname”(在/usr/lib/python2.7/site-packages/urllib3/packages/中)重命名为“ssl_match_hostname.old”,您可以删除新生成的链接(例如:“ssl_match_hostname;5bf4fd46”),然后再次安装 python-urllib3.noarch。这对我有用。

于 2018-11-29T02:43:17.007 回答