![](/img/trans.png)
[英]python InsecurePlatformWarning when downloading pip on Windows (python 2.7.5)
[英]Python PIP and InsecurePlatformWarning
我正在嘗試安裝Python的requests
庫(CentOS6上的2.6.6)
sudo pip install requests[security]
我收到這些錯誤消息:
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
Collecting requests[security]
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
/usr/lib/python2.6/site-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
我確保所有系統庫都到位
sudo yum install openssl-devel python-devel libffi-devel
一切都很好
所以我試過了
sudo pip install pyopenssl ndg-httpsclient pyasn1
和
sudo pip install --trusted-host pypi.python.org requests
而這些也失敗了。
由於一些舊代碼,我需要堅持使用Python 2.6
知道這里出了什么問題以及如何解決它?
PS
我已經決定降級pip
,它出現了pip
版本6.1+的錯誤。 對此的想法?
實際上,截至2019年,由於各種限制,他們無法升級他們的系統Python(以及系統提供的openssl),因此很多人仍然面臨這個問題。
如果你想修復InsecurePlatformWarning .. (Caused by SSLError .. SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version')
,以下解決方案可以幫助使用舊Linux發行版的人:
無法在Ubuntu Linux中使用pip安裝Python軟件包:InsecurePlatformWarning,SSLError,tlsv1警報協議版本
CentOS6上的Python 2.6.6
在您的特定情況下,官方支持Python 2.6的最后一個cryptography
版本是cryptography-2.1.1,盡管較新版本可能有效。 第一個manylinux1加密軟件包包含自己的OpenSSL(1.1.0f)Linux共享庫綁定,無論您的平台上有什么,都出現在cryptography-2.0版本中。 仍然官方支持Centos 6.4的最后一個加密版本是1.8.2版本,而較新的版本僅官方支持CentOS 7.x: https : //pypi.org/project/cryptography/#files
請注意,加密版本<2.0沒有manylinux1
並且沒有manylinux1
的openssl / ssllib,僅依賴於系統提供的版本(當時,他們僅針對其他具有更大SSL問題的操作系統)。 雖然cryptography-2.0(manylinux1)仍然值得嘗試,但您可能必須在Centos 6.x上本地編譯較新的openssl版本(1.0.1 - 1.1.0),然后再編譯加密1.8.2以鏈接它:
https://cryptography.io/en/latest/installation/#using-your-own-openssl-on-linux
https://cryptography.io/en/latest/installation/#rhel-centos
還可以選擇構建自己的靜態鏈接輪,這些輪可以在您自己的系統上運行:
https://cryptography.io/en/latest/installation/#static-wheels
那說,
如果您只需要安裝requests
lib(無需解決臭名昭着的SSLError),特別是在CentOS6上的Python 2.6.6中,並且您不需要requests
TLS 1.2協議支持,您可以簡單地使用Centos repo那:
$ yum search requests
$ sudo yum install python26-requests
或者,您可以采用與上述解決方案類似的方式獲取和安裝requests
,來自輪子或從以下網址下載的tar.gz: https : //pypi.org/project/requests/
注意,關於PyPI的最新requests
取決於以下Python包:urllib3,idna,chardet,certifi
幸運的是,這四個沒有其他依賴關系,可以直接從PyPI獲得,以相同的方式 - 在PyPI上的“下載文件”部分:
https://pypi.org/project/urllib3/
https://pypi.org/project/idna/
https://pypi.org/project/chardet/
https://pypi.org/project/certifi/
您可以下載並嘗試安裝其最新版本,或使用“發布歷史記錄”部分查找舊版本,具體取決於您的用例和系統特定要求。
注意,現在許多Web服務器(包括PyPI)都需要TLS 1.2支持,無論是在客戶端還是服務器后端,都要建立HTTPS連接,所以如果你需要這種類型的連接,如果不按照討論的方式修復SSLError, requests
將無法工作上面(或者通過編譯一個較新的Python 2.7.9+來對抗OpenSSL版本1.0.2+, 在編譯新的Python 之前必須編譯,以便將ssl
模塊與它連接起來)。
嘗試這個:
sudo pip安裝請求
[安全]沒有必要
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.