python-urllib3 未正确安装时出现 Certbot Renew 错误

python-urllib3 未正确安装时出现 Certbot Renew 错误

当我尝试更新我的证书时出现以下错误,对此有什么想法吗?

[root@ centos]# certbot renew --dry-run

Traceback (most recent call last):
  File "/bin/certbot", line 9, in <module>
    load_entry_point('certbot==0.39.0', 'console_scripts', 'certbot')()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 378, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2566, in load_entry_point
    return ep.load()
  File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2260, in load
    entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/usr/lib/python2.7/site-packages/certbot/main.py", line 17, 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 11, in <module>
    from acme import challenges
  File "/usr/lib/python2.7/site-packages/acme/challenges.py", line 12, 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'

然后我尝试安装 urllib3,但由于以下错误而失败

[root@ip- centos]# yum install python-urllib3
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: centos.mirrors.estointernet.in
 * epel: repos.del.extreme-ix.org
 * extras: centos.mirrors.estointernet.in
 * remi-php72: rpms.remirepo.net
 * updates: centos.hbcse.tifr.res.in
Resolving Dependencies
--> Running transaction check
---> Package python-urllib3.noarch 0:1.10.2-7.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=================================================================================================================================================================================
 Package                                        Arch                                   Version                                        Repository                            Size
=================================================================================================================================================================================
Installing:
 python-urllib3                                 noarch                                 1.10.2-7.el7                                   base                                 103 k

Transaction Summary
=================================================================================================================================================================================
Install  1 Package

Total download size: 103 k
Installed size: 380 k
Is this ok [y/d/N]: y
Downloading packages:
python-urllib3-1.10.2-7.el7.noarch.rpm                                                                                                                    | 103 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : python-urllib3-1.10.2-7.el7.noarch                                                                                                                            1/1
**Error unpacking rpm package python-urllib3-1.10.2-7.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
  Verifying  : python-urllib3-1.10.2-7.el7.noarch**                                                                                                                            1/1

**Failed:
  python-urllib3.noarch 0:1.10.2-7.el7**

Complete!

有什么办法可以解决这个问题吗?

答案1

尝试移动/usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname目录/文件并重试。文件和目录之间可能存在冲突。

答案2

我尝试安装时遇到了同样的错误: IEsudo yum update && sudo yum -y install zsh

我得到了以下几行:

Loaded plugins: amazon-id, langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
Resolving Dependencies
--> Running transaction check
---> Package python-urllib3.noarch 0:1.10.2-5.el7 will be updated
---> Package python-urllib3.noarch 0:1.10.2-7.el7 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

==============================================================================================================================================================
 Package                               Arch                          Version                             Repository                                      Size
==============================================================================================================================================================
Updating:
 python-urllib3                        noarch                        1.10.2-7.el7                        rhel-7-server-rhui-rpms                        103 k

Transaction Summary
==============================================================================================================================================================
Upgrade  1 Package

Total download size: 103 k
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for rhel-7-server-rhui-rpms
python-urllib3-1.10.2-7.el7.noarch.rpm                                                                                                 | 103 kB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : python-urllib3-1.10.2-7.el7.noarch                                                                                                         1/2
Error unpacking rpm package python-urllib3-1.10.2-7.el7.noarch
error: unpacking of archive failed on file /usr/lib/python2.7/site-packages/urllib3/packages/ssl_match_hostname: cpio: rename
  Verifying  : python-urllib3-1.10.2-7.el7.noarch                                                                                                         1/2
python-urllib3-1.10.2-5.el7.noarch was supposed to be removed but is not!
  Verifying  : python-urllib3-1.10.2-5.el7.noarch                                                                                                         2/2

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

要解决这个问题:运行此命令:sudo pip uninstall urllib3

然后任何一个: 跑步

a. 重新安装:sudo pip install urllib3

或更好

b. sudo yum update && sudo yum -y install zsh(这就是我想要的,zsh 将最新版本作为依赖项)。

相关内容