我最近发现一点对我来说完全坏了。这是在Ubuntu仿生18.04上。
$ pip --version
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
File "/usr/lib/python2.7/dist-packages/pip/__init__.py", line 22, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python2.7/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 4, in <module>
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/__init__.py", line 84, in <module>
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import crypto, SSL
File "/usr/lib/python2.7/dist-packages/OpenSSL/crypto.py", line 12, in <module>
from cryptography import x509
File "/usr/lib/python2.7/dist-packages/cryptography/x509/__init__.py", line 8, in <module>
from cryptography.x509.base import (
File "/usr/lib/python2.7/dist-packages/cryptography/x509/base.py", line 16, in <module>
from cryptography.x509.extensions import Extension, ExtensionType
File "/usr/lib/python2.7/dist-packages/cryptography/x509/extensions.py", line 18, in <module>
from cryptography.hazmat.primitives import constant_time, serialization
File "/usr/lib/python2.7/dist-packages/cryptography/hazmat/primitives/constant_time.py", line 9, in <module>
from cryptography.hazmat.bindings._constant_time import lib
AttributeError: 'module' object has no attribute '_init_cffi_1_0_external_module'
我看过其他参考文献,但它们与我的情况不符,或者没有答案:
我该如何解决?
答案 0 :(得分:0)
看了更多之后,我发现上面的Fedora错误报告具有真正有用的信息:
在某些时候,来自pip的cffi 1.1.2被python-cffi软件包中的cffi 0.8.6覆盖。加密1.1.2正在调用cffi_1_0_external_module'时,它不存在,因此失败。
我四处搜寻,发现我在cffi
中有一个过时的~/.local/lib/python2.7/site-packages/
版本(大概是几年前的pip install --user ...
了)。
探索和检查版本的一般方法是:
>>> import cffi
>>> cffi.__version__
'0.8.6'
>>> cffi
<module 'cffi' from '$HOME/.local/lib/python2.7/site-packages/cffi/__init__.pyc'>
删除该目录中固定的pip,但大概可以与我很久以前安装的其他东西配合使用。
我还听说在某些相关情况下使用easy_install(由于pip无法正常工作...)可以升级cffi:
easy_install -U cffi
我仍然很好奇,这里是否有很多关于将来如何避免这种事情的课程。