CentOS7、OpenCloudOS7 源码编译安装python3.12

2024-07-01 10:54:44 浏览数 (2)

python3.12用的openssl11

代码语言:txt复制
openssl11 version
OpenSSL 1.1.1k  FIPS 25 Mar 2021

openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

代码语言:txt复制
yum update -y
yum install epel-release -y
yum install libffi-devel -y
yum install openssl-devel openssl11 openssl11-devel -y
export CFLAGS=$(pkg-config --cflags openssl11)
export LDFLAGS=$(pkg-config --libs openssl11)


yum groupinstall -y "Development Tools"
yum install -y zlib-devel bzip2-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make gdbm-devel db4-devel libpcap-devel xz-devel

yum install aria2 -y
#aria2c https://www.python.org/ftp/python/3.12.4/Python-3.12.4.tgz
aria2c 你的下载链接(python官网的下载链接太慢了,我下载后存了一份到自己COS)

#这里是配置swap,如果不配置,2GB内存的机器大概率会报out of memory
fallocate -l 2048M /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
mount -a
free -m

tar zxvf Python-3.12.4.tgz
cd Python-3.12.4
./configure --with-openssl=/usr/bin/openssl11
make -j
make altinstall

ls -lh /usr/local/bin/python3.12 /usr/local/bin/pip3.12
/usr/local/bin/python3.12 -m pip install --upgrade pip
/usr/local/bin/pip3.12 -V
pip -V
pip3 -V
pip3 config set global.index-url http://mirrors.tencentyun.com/pypi/simple
pip3 config set global.trusted-host mirrors.tencentyun.com

rm -rf /usr/bin/python3
rm -rf /usr/bin/pip3
ln -s /usr/local/bin/python3.12 /usr/bin/python3
ln -s /usr/local/bin/pip3.12 /usr/bin/pip3
python3 -m pip install --upgrade pip

ssh客户端工具,windows上我用的PortX,非常好用

0 人点赞