1.下载安装相关依赖,用来下载编译python3
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gcc make
2.安装epel扩展源,相当于新增加了一个yum源
yum -y install epel-release
3.安装pip工具
yum -y install python-pip
4.安装wget,通过wget在线下载python3安装包。这里也可以不安装,手动去官网下载对应安装包上传到虚拟机
pip install wget
wget https://www.python.org/ftp/python/3.10.10/Python-3.10.10.tgz
5.解压下载的安装包,目录随意
tar -Jxvf Python-3.10.10.tar.xz
6.切换到解压目录,编译安装
cd /usr/local/Python-3.10.10/
./configure prefix=/usr/local/python3
优化选项命令
./configure --enable-optimizations
make && make install
出现如下表示安装成功
此时在/usr/local/下会生成一个名为python3的文件夹,进入该文件夹下的bin目录,将软链接python3复制到/usr/bin/目录下,就可以在全局使用python3命令了。
cd /usr/local/python3/bin/
cp python3 /usr/bin/
验证一下是否安装成功
![](https://common.cnblogs.com/images/loading.gif)
标签:centos,python,devel,usr,install,安装,python3 From: https://www.cnblogs.com/yecao8888/p/17144169.html