centos7编译安装python3
1.安装依赖
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make libffi-devel
2.下载软件包
wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tar.xz
下载列表:https://www.python.org/ftp/python/
3.编译安装
wget http://www.openssl.org/source/openssl-1.1.1.tar.gz
tar xf openssl-1.1.1.tar.gz
cd openssl-1.1.1/
./config --prefix=/usr/local/openssl shared zlib
make && make install
tar -xf Python-3.9.7.tar
cd Python-3.9.7
./configure --prefix=/usr/local/python3.9 --with-ssl=/usr/local/openssl
make && make install
如果使用系统默认版本,默认系统OpenSSL版本不适配,需要升级
yum install -y epel-release.noarch yum install -y openssl11 openssl11-devel cd Python-3.10.xxx #进入目录后替换编译命令 # 替换openssl 为openssl11 sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
4.配置PATH及验证
vim ~/.bash_profile
PATH=/usr/local/python3.9/bin:$PATH:$HOME/bin
. ~/.bash_profile
env python3
"一劳永逸" 的话,有是有的,而 "一劳永逸" 的事却极少