centos7-安装python3.10

centos7-安装python3.10

遇到问题

1
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.

问题分析

1
2
由于python3.10之后版本不在支持libressl使用ssl,需要使用openssl安装来解决编译安装
python时候遇到的ssl模块导入失败的问题,这里需要用的openssl1.1.1版本或者更高版本

安装步骤

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
## 安装openssl
wget https://www.openssl.org/source/openssl-1.1.1t.tar.gz --no-check-certificate
./config --prefix=/usr/local/openssl-1.1.1t
make && make install

## 安装python
wget https://registry.npmmirror.com/-/binary/python/3.10.11/Python-3.10.11.tgz
./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl-1.1.1t
make && make install
ln -sf /usr/local/python3/bin/python3 /usr/bin/python3
ln -sf /usr/local/python3/bin/pip3 /usr/bin/pip3

## 升级pip
python3 -m pip install --upgrade pip

## 验证
python3 -V
Python 3.10.11
pip3 -V
pip 23.1.2 from /usr/local/python3/lib/python3.10/site-packages/pip (python 3.10)