目錄
1.問題描述:
2.問題分析:
3.問題解決:
1.問題描述:
ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2k-fips? 26 Jan 2017'. See: https://github.com/urllib3/urllib3/issues/2168
提示
這個錯誤表明 urllib3
版本 2.0 要求使用 OpenSSL 1.1.1 或更高版本,但當(dāng)前的 Python ssl
模塊是用 OpenSSL 1.0.2k-fips 編譯的。
2.問題分析:
當(dāng)前OpenSSL版本不支持現(xiàn)有的Urllib3
3.問題解決:
①降級Urllib(不推薦)
pip3 install urllib3==1.25.11 # 或者其他你認(rèn)為合適的版本號
②升級 openssl(推薦)
1.安裝wget
yum install -y wget
2.編譯安裝 openssl
wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz --no-check-certificate
tar zxf openssl-1.1.1n.tar.gz -C 指定目錄
cd openssl-1.1.1n/
./config --prefix=/usr/local/openssl 設(shè)置安裝目錄 可以自定義 但是要記住,后面會用到
make -j && make install 編譯并安裝
/usr/local/openssl/lib 路徑添加到系統(tǒng)動態(tài)庫查找路徑中,在 etc 目錄下的 profile文件最后面添加下面這一行
export LD_LIBRARY_PATH=/usr/local/openssl/lib:$LD_LIBRARY_PATH
?source /etc/profile??????? 使其生效
3.重新編譯安裝 python
cd python安裝目錄
// 下面這兩行如果做過了,可以不做
已經(jīng)編譯過的可以先 make clean 清理一下
yum install libffi-devel -y 安裝 libffi-devel ,這個是為了 _ctypes 模塊
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-ssl-default-suites=openssl --with-system-ffi
make -j && make install
4.檢查 Python 的 ssl
模塊版本:
python3.8 -c "import ssl; print(ssl.OPENSSL_VERSION)"
若為此
[root@slave1 Python-3.8.2]# python3.8 -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 1.1.1n? 15 Mar 2022文章來源:http://www.zghlxwxcb.cn/news/detail-752450.html
則表示升級成功!??! 文章來源地址http://www.zghlxwxcb.cn/news/detail-752450.html
到了這里,關(guān)于【Python爬蟲】ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the ‘ssl‘ module is comp的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!