python3中No module named _ssl的問題解決
一、原因
因openssl 1.0.1存在安全問題,python3自3.7版本后要求依賴openssl 1.0.2以上或libressl;錯誤提示如下:Python requires an OpenSSL 1.0.2 or 1.1 compatible libssl with X509_VERIFY_P
python3.7以上建議使用libressl代替openssl,故需通過源碼編譯安裝libressl
二、解決
# 下載源碼包 wget https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/libressl-3.0.2.tar.gz # 解壓 tar -zxvf libressl-3.0.2.tar.gz cd libressl-3.0.2 # 配置安裝路徑 mkdir /usr/local/libressl ./configure --prefix=/usr/local/libressl # 安裝 make -j8 make install # 創(chuàng)建軟連接代替openssl mv /usr/bin/openssl /usr/bin/openssl.bak mv /usr/include/openssl /usr/include/openssl.bak ln -s /usr/local/libressl/bin/openssl /usr/bin/openssl ln -s /usr/local/libressl/include/openssl /usr/include/openssl echo /usr/local/libressl/lib >> /etc/ld.so.conf.d/libressl-3.0.2.conf ldconfig -v
驗證是否安裝完成
openssl version
設(shè)置環(huán)境變量
export LDFLAGS="-L/usr/local/libressl/lib" export CPPFLAGS="-I/usr/local/libressl/include" export PKG_CONFIG_PATH="/usr/local/libressl/lib/pkgconfig"
配置編譯安裝python
./configure --prefix=/usr/local/python37 make make install
驗證ssl 安裝正確
import ssl沒有報錯
到此這篇關(guān)于python3中No module named _ssl的問題解決的文章就介紹到這了,更多相關(guān)python3 No module named _ssl內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python教程pandas數(shù)據(jù)分析去重復值
Pandas指定行進行去重更新值,加載數(shù)據(jù)sample抽樣函數(shù),指定需要更新的值append直接添加append函數(shù)用法,根據(jù)某一列key值進行去重key唯一2021-09-09
python GUI庫圖形界面開發(fā)之PyQt5開發(fā)環(huán)境配置與基礎(chǔ)使用
這篇文章主要介紹了python GUI庫圖形界面開發(fā)之PyQt5開發(fā)環(huán)境配置與基礎(chǔ)使用,需要的朋友可以參考下2020-02-02
一文了解Python并發(fā)編程的工程實現(xiàn)方法
這篇文章主要介紹了Python并發(fā)編程的工程實現(xiàn),本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-05-05
在Python下使用Txt2Html實現(xiàn)網(wǎng)頁過濾代理的教程
這篇文章主要介紹了在Python下使用Txt2Html實現(xiàn)網(wǎng)頁過濾代理的教程,來自IBM官方開發(fā)者技術(shù)文檔,需要的朋友可以參考下2015-04-04

