由于python3.10之后版本不在支持libressl使用ssl,需要使用openssl安装来解决编译安装 python时候遇到的ssl模块导入失败的问题,这里需要用的openssl1.1.1版本或者更高版本
https://www.cdsy.xyz/computer/system/linux/240623/cd61930.html
我安装的版本是3.1.2
找到下面代码 把注释去掉 改成自己安装目录 或者直接复制在文件结尾
- OPENSSL=/usr/local/openssl
- _ssl _ssl.c \
- -I$(OPENSSL)/include -L$(OPENSSL)/lib64 \ (看openssl安装目录下面是lib 还是lib64 改成跟自己安装目录一样)
- -lssl -lcrypto
- _hashlib _hashopenssl.c \
- -I$(OPENSSL)/include -L$(OPENSSL)/lib64 \
- -lcrypto
- cd /usr/local/python3.10/Python-3.10.7
- ./configure --prefix=/usr/local/python3.10 --enable-optimizations --with-openssl=/usr/local/openssl --with-ensurepip=yes CFLAGS="-I/usr/local/openssl/include" LDFLAGS="-L/usr/local/openssl/lib64"
- make && make altinstall