1、去python3的官方网站下载源代码
https://www.python.org/downloads/
下载安装Python 3.8.12到/opt/python3
cd /opt
wget https://www.python.org/ftp/python/3.8.12/Python-3.8.12.tar.xz
tar -xvJf Python-3.8.12.tar.xz
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-devellibpcap-devel xz-devel
yum install libffi-devel -y
mkdir /opt/python3
cd Python-3.8.12
./configure --prefix=/opt/python3
#如果特别安装过指定路径的高版本的openssl可以用以下命令操作
#./configure --prefix=/opt/python3 --with-openssl=/opt/openssl --with-openssl-rpath=auto
make
make install
导入到全局变量,使得Python3命令可全局执行
echo PATH="/opt/python3/bin:$PATH" >> /etc/profile
source /etc/profile
mkdir ~/.pip
vim ~/.pip/pip.conf
pip3 install virtualenv
标签:opt,12,Python,devel,CentOS7,python3,3.8 From: https://www.cnblogs.com/Magiclala/p/17169236.html