python2 和 OpenSSL 不能在 Kali 上一起运行 - 如何修复?

python2 和 OpenSSL 不能在 Kali 上一起运行 - 如何修复?

我有一个 Kali Linux 发行版,它是 amd64 上的 Kali GNU/Linux Rolling(当前版本 2017.3)。我会定期更新它,并且不会干扰系统文件或包管理。然而,不久前 python2 和 OpenSSL 不再一起使用。一开始这很奇怪,但现在却成了一个大麻烦。例如,像这样的简单调用会失败:

# pip
/usr/lib/python2.7/dist-packages/cffi/model.py:532: UserWarning: 'point_conversion_form_t' has no values explicitly defined; guessing that it is equivalent to 'unsigned int'
  % self._get_c_name())
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 21, 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.12.4-py2.py3-none-any.whl/requests/__init__.py", line 52, in <module>
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 59, in <module>
  File "/usr/share/python-wheels/requests-2.12.4-py2.py3-none-any.whl/requests/packages/__init__.py", line 32, in vendored
  File "/usr/share/python-wheels/urllib3-1.19.1-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 47, in <module>
  File "/usr/lib/python2.7/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import rand, crypto, SSL
  File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 112, in <module>
    if _lib.Cryptography_HAS_SSL_ST:
AttributeError: 'FFILibrary' object has no attribute 'Cryptography_HAS_SSL_ST'

仔细筛选各种搜索引擎结果,我发现这似乎是一个已知的不兼容问题,但显然没有切实可行的解决方案。让我困惑的是,在一个积极维护的发行版中怎么会发生这种情况? (事实上​​,同样设置的同事不会有这个问题。)

有没有一种简单的方法可以修复/修复此问题而无需重新安装整个发行版?

安装的版本是 python/kali-rolling 2.7.14-1、python-openssl/kali-rolling 16.2.0-1 和 python-cffi/kali-rolling 1.9.1-2。

答案1

我假设您已经pip从发行版存储库安装了?

如果是这样,只需删除当前版本pip并安装它获取 pip.py:

curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py
python3 ./get-pip.py
python2 ./get-pip.py

这应该会提取所有适当的依赖项,并且您pip将再次开始工作。

答案2

罪魁祸首/usr/lib/python2.7/dist-packages是东西 - 感谢 strace。删除它解决了这个问题。

经验教训:对需要非标准包的程序使用虚拟环境。

相关内容