centos 7.8 7.9安装python3.9并解决pip install时报错SSL问题

  

按网上流程安装使用pip时会报错如下内容
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
正确安装方式如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
yum install wget screen -y && screen -S lnmp
sudo yum check-update || sudo yum update -y
yum groupinstall -y 'Development Tools'
yum install -y epel-release
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 bzip2-devel libffi-devel perl perl-devel perl-ExtUtils-Embed libxslt libxslt-devel libxml2 libxml2-devel gd gd-devel GeoIP GeoIP-devel

wget https://www.python.org/ftp/python/3.9.0/Python-3.9.0.tar.xz

tar -xvJf Python-3.9.0.tar.xz

mkdir /usr/local/python3
cd Python-3.9.0

./configure --prefix=/usr/local/python3 --with-ssl-default-suites=openssl

make && make install

如果之前安装有其他版本,需要先删除(注意检查是路径是/usr/bin/python3还是/usr/local/bin/python3)
mv /usr/bin/python3 /tmp/
mv /usr/bin/pip3 /tmp/

ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3

验证:

1
2
python3 -V
pip3 -V

报歉!评论已关闭.