不灭的火

革命尚未成功,同志仍须努力下载JDK17

作者:AlbertWen  添加时间:2022-03-12 21:09:03  修改时间:2025-06-12 12:26:29  分类:06.Linux软件安装  编辑

Python历史版本:


1、安装依赖关系:

yum -y install zlib-devel xz-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make

2、下载源码包

cd /alidata/tmp
wget -c https://www.python.org/ftp/python/3.10.18/Python-3.10.18.tgz

3、解压、编译、安装

# 解压
tar -xzvf ./Python-3.10.18.tgz

# 编译
cd Python-3.10.18

# 以下编译只适合 Python 3.9
# ./configure --enable-optimizations

# 【注意】Python 3.10及以后的版本,需要自己链接openssl
./configure --with-zlib=/usr/include/ --with-openssl-rpath=auto  --with-openssl=/usr/include/openssl  OPENSSL_LDFLAGS=-L/usr/include/openssl   OPENSSL_LIBS=-l/usr/include/openssl/ssl OPENSSL_INCLUDES=-I/usr/include/openssl

make -j 4
make altinstall  # 跳过创建python链接和手册页链接的操作

# 建立软连接
mv /usr/bin/python3 /usr/bin/python3.bak
ln -s /usr/local/bin/python3.10 /usr/bin/python3
mv /usr/bin/pip3 /usr/bin/pip3.bak
ln -s /usr/local/bin/pip3.10 /usr/bin/pip3

4、检测版本

python3 -V   # 查看python版本
pip3 list  # 查看pip3是否安装成功

5、永久设置pip3为国内镜像

 

 

参考:

  1. Python安装:make installmake altinstall的差别
  2. Python3.10及以上版本编译安装ssl模块