安装后使用pip3如遇ssl错误请先安装openssl在安装python3
wget https://www.openssl.org/source/openssl-3.0.7.tar.gz --no-check-certificate
tar -zxf openssl-3.0.7.tar.gz
cd openssl-3.0.7
./Configure --prefix=/usr/local/openssl
make -j && make install
rm -rf /usr/include/openssl /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so /usr/local/lib64/libssl.so
ln /usr/local/openssl/bin/openssl /usr/bin
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
#使修改后的/etc/ld.so.conf生效
ldconfig -v
export LDFLAGS=" -L/usr/local/openssl/lib"
export CPPFLAGS=" -I/usr/local/openssl/include"
export PKG_CONFIG_PATH="/usr/local/openssl/lib/pkgconfig"
rm -rf /usr/lib/libssl.so.3 /usr/lib/libcrypto.so.3 /lib64/libcrypto.so.3 /lib64/libssl.so.3
ln -s /usr/local/lib/libssl.so.3 /usr/lib/libssl.so.3
ln -s /usr/local/lib/libcrypto.so.3 /usr/lib/libcrypto.so.3
ln -s /usr/local/openssl/lib64/libcrypto.so.3 /lib64/libcrypto.so.3
ln -s /usr/local/openssl/lib64/libssl.so.3 /lib64/libssl.so.3
openssl version
正确显示版本号表示安装完成
安装环境依赖
dnf install -y zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
下载并解压进入目录
wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz
tar -zxvf Python-3.11.0.tgz
cd Python-3.11.0
编译安装
./configure --enable-shared --with-openssl=/usr/local/openssl
./configure --enable-optimizations
make
make install
配置更新源
pip3 config set global.index-url https://mirrors.aliyun.com/pypi/simple/
评论区