注:本博文主要為轉(zhuǎn)載后根據(jù)本人情況再加工 1 問(wèn)題: python3.7.2安裝遇到如下ssl問(wèn)題 >>> import ssl Traceback (most recent call last): File "", line 1, in File "/usr/local/lib/python3.7/ssl.py", line 98, in import _ssl # if we can't import it, let the error propagate ModuleNotFoundError: No module named '_ssl' 2 解決辦法 2.1安裝依賴(lài) yum groupinstall development 2.2 安裝libressl代替openssl-devel 2.2.1 原因 由于系統(tǒng)的openssl是1.0.1的版本,,對(duì)于python3.7太老了,,需要更新為openssl1.0.2或者libressl2.64(不含)以后的版本,,所以這里從libressl官網(wǎng)下載libressl源碼,,編譯生成庫(kù)文件代替系統(tǒng)的openssl1.0.1 2.2.2 安裝libressl 下載libressl-2.8.0 ./config –prefix=/usr/local/libressl make make intall 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 2.2.3 加載lib cd /etc/ld.so.conf.d 新建文件 vim libressl-2.8.0.conf #將以下行加入文件,,并保存 /usr/local/libressl/lib ldconfig -v #重新加載庫(kù)文件 2.3安裝python3.7 從官網(wǎng)下載python3.7的源碼, 解壓后進(jìn)入Python-3.7.0 編譯前需要設(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" ./configure –prefix=/usr/local/python3 –enable-shared CFLAGS=-fPIC 運(yùn)行后會(huì)出現(xiàn)一堆信息: 注意最后的ssl檢查,,如下圖所示: 2.4 處理異常 運(yùn)行python3.7命令遇到:libpython3.7m.so.1.0: cannot open shared object file: No such file or d echo /usr/local/python3.7/lib > /etc/ld.so.conf.d/python3.7.conf ldconfig -v 2.4 驗(yàn)證 linux下gunicorn+flask項(xiàng)目的部署 |
|
來(lái)自: LibraryPKU > 《Python》