Kali-Linux
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。
裡面的東西
/usr/lib/python2.7/dist-packages
是罪魁禍首——多虧了 strace。刪除它解決了這個問題。經驗教訓:對需要非標準包的程序使用虛擬環境。
我假設您已經
pip
從分發儲存庫安裝?如果是這樣,只需刪除目前版本並使用get-pip.py
pip
安裝它:curl -o ./get-pip.py https://bootstrap.pypa.io/get-pip.py python3 ./get-pip.py python2 ./get-pip.py
這應該會提取所有適當的依賴項,您
pip
將重新開始工作。