python新版本需要openssl 1.1.1,以支持ssl及pip下载。
1.安装openssl 1.1.1及测试
#从官网下载
# wget https://www.openssl.org/source/openssl-1.1.1n.tar.gz
#腾讯云提供的镜像
wget https://mirrors.cloud.tencent.com/openssl/source/openssl-1.1.1n.tar.gz
编译 openssl
tar -xvf openssl-1.1.1g.tar.gz
cd openssl-1.1.1g
./config shared --openssldir=/usr/local/openssl --prefix=/usr/local/openssl
make && make install
配置ssl
mv /usr/bin/openssl /usr/bin/openssl.old
mv /usr/lib/openssl /usr/lib/openssl.old
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig -v
查看版本:
/wk/tools/openssl$ openssl version
OpenSSL 1.1.1n 15 Mar 2022
验证ssl编译:
#include
#include
int main(){
OpenSSL_add_all_algorithms();
return 0;
}
gcc -o conftest -I/usr/local/openssl/include/ -L/usr/local/openssl/lib test_openssl.c -lssl -lcrypto -lcrypt -lpthread -ldl -lutil -lm
编译通过
2 python编译配置:
下载python版本
./configure --enable-optimizations --prefix=/opt/python3.9 --with-openssl=/usr/local/openssl --with-computed-gotos --enable-loadable-sqlite-extensions --enable-shared
make
make install
编辑 /etc/ld.so.conf.d/python3.conf 添加一行
/opt/python3.9/lib/
ldconfig
import ssl正常:
$ /opt/python3.9/bin/python3
Python 3.9.12 (heads/master:227f566, May 1 2022, 22:05:04)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>>
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)