CentOS 安装Python3.7,并解决pip is configured with locations that require TLS/SSL错误

1. 首先安装相关依赖库

yum -y groupinstall "Development tools"
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

2. 升级openSSL

系统版本centos6.5,其中openssl的版本为OpenSSL 1.0.1e-fips 11 Feb 2013,而python3.7需要的openssl的版本为1.0.2或者1.1.x,需要对openssl进行升级,并重新编译python3.7.0。yum 安装的openssl 版本都比较低。

# 下载openssl
wget https://www.openssl.org/source/openssl-1.1.1a.tar.gz
# 解压
tar -zxvf openssl-1.1.1a.tar.gz
# 进入资源目录
cd openssl-1.1.1a
# 配置编译并安装
./config --prefix=/usr/local/openssl no-zlib 
make && make install

# 备份原来的配置
mv /usr/bin/openssl /usr/bin/openssl.bak
mv /usr/include/openssl/ /usr/include/openssl.bak
# 新版配置
ln -s /usr/local/openssl/include/openssl /usr/include/openssl
ln -s /usr/local/openssl/lib/libssl.so.1.1 /usr/local/lib64/libssl.so
ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl
# 修改系统配置
# 写入openssl库文件的搜索路径
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
# 使修改后的/etc/ld.so.conf生效
ldconfig -v
# 查看openssl版本
openssl version

3. 下载python3.7源码解压并编译

# 下载
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tar.xz
# 解压
tar -xvJf Python-3.7.1.tar.xz
# 进入资源目录
cd Python-3.7.1

# 配置编译并安装
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
make
make install
centos安装python3.7到此结束,仔细完成以上步骤,使用pip3安装库时不会再出现TSL/SSL报错的问题。

weinxin
我的微信
有问题微信找我
DannyWu

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: