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)文章
anaconda安裝pytorch1.7.1和torchvision0.8.2的方法(親測可用)
這篇文章主要介紹了anaconda安裝pytorch1.7.1和torchvision0.8.2的方法(親測可用),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2021-02-02python實現(xiàn)sm2和sm4國密(國家商用密碼)算法的示例
這篇文章主要介紹了python實現(xiàn)sm2和sm4國密(國家商用密碼)算法的示例,幫助大家使用python加密文件,感興趣的朋友可以了解下2020-09-09Python實現(xiàn)多維數(shù)據(jù)分析的示例詳解
多維數(shù)據(jù)分析是對數(shù)據(jù)的信息分析,它考慮了許多關(guān)系,這篇文章主要為大家詳細(xì)介紹了一些使用Python分析多維/多變量數(shù)據(jù)的基本技術(shù),希望對大家有所幫助2023-11-11python 通過麥克風(fēng)錄音 生成wav文件的方法
今天小編就為大家分享一篇python 通過麥克風(fēng)錄音 生成wav文件的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2019-01-01使用pyinstaller打包py文件的實現(xiàn)步驟
PyInstaller是一個用于將Python腳本打包成獨立可執(zhí)行文件的工具,本文主要介紹了使用pyinstaller打包py文件,具有一定的參考價值,感興趣的可以了解一下2025-03-03