【Python3.10.4】Centos7 ,centos8,centos9源码安装 python3.10.4 解释器
1.检查是否安装wget如果没有安装则:
终端执行:
yum -y install wget
2.下载python3源码包
终端执行:
wget https://www.python.org/ftp/python/3.10.4/Python-3.10.4.tgz
如何找到最新稳定版源码包?
首先 进入python官网点击 进入 Welcome to Python.org
点击源码下载
下载稳定发布版 或者右键点击复制链接 使用wget 下载
3.下载python3相关依赖包
终端执行:
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel xz-devel gdbm-devel db4-devel libpcap-devel
CentOS 9 Stream,终端执行:
yum install -y gcc patch libffi-devel python-devel zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel xz-devel
gdbm-devel db4-devel libpcap-devel
baocuo,
4.解压源码包
终端执行:
tar -zxvf Python-3.10.4.tgz //根据自己下载的版本解压号解压
5.指定安装目录
进入解压下来的文件夹
终端执行:
cd Python-3.10.4 //根据自己下载的版本解压号解压
指定安装目录/opt/python310,也可以自定义
终端执行:
./configure --prefix=/opt/python310
6.进行编译安装
终端执行:
make && make install
7.配置环境变量
打开配置文件profile
终端执行:
vim /etc/profile
在末尾添加PATH
PATH=/opt/python310/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
ESC key--->:wq ---->
重载配置文件
终端执行:
source /etc/profile
8.检查是否安装成功
终端执行:
python3 -V
or
python3 --version
————————————————
cankaowenzhang:https://blog.csdn.net/m0_56641407/article/details/123983545