#安装python3所需依赖
yum install libffi-devel
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
#创建存放目录
mkdir /usr/local/python3
cd /usr/local/python3
#下载python3源码
wget https://www.python.org/ftp/python/3.7.1/Python-3.7.1.tgz
解压到
tar -xzvf Python-3.7.1.tgz
#进入解压后的目录进行编译,./configure指定安装目录
cd Python-3.7.1.tgz
./configure --enable-optimizations --prefix=/usr/local/python3
#进行make和make install
make && make altinstall
#删除临时文件
make clean
#创建软链接
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
#查看是否安装成功
python3
linux安装python3
最新推荐文章于 2023-11-17 16:01:38 发布