redhat9.3版本之Python3.9.18降级为3.7.2版本(编译安装python)

有一些场景需要把python进行降级,以下为操作步骤,请先看下全过程再操作,谢谢。

查看操作系统以及内核版本:
在这里插入图片描述

在这里插入图片描述目前操作系统为redhat-9.3版本,自带python版本为3.9.18

    1. 安装Python解释器
# rpm -aq | grep zlib 可以先依次检查以下依赖包是否安装
yum -y install zlib zlib-devel libffi-devel openssl openssl-devel
    1. 下载python解释器源码安装包
cd  /opt/
wget https://www.python.org/ftp/python/3.7.2/Python-3.7.2.tgz
tar -xvf Python-3.7.2.tgz

Python官网链接:https://www.python.org/ftp/python/
看自身需求下载哪个版本就下载哪个版本

    1. 进入解压后的目录,执行安装配置安装到/usr/python3文件
cd Python-3.7.2
./configure --prefix=/usr/local/python3    # 安装至/usr/local/python3

安装的时候如有以下报错则进行gcc-c++安装,具体报错具体分析哈

[root@gauss01 Python-3.7.2]# ./configure --prefix=/usr/local/python3
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking for python3.7... no
checking for python3... python3
checking for --enable-universalsdk... no
checking for --with-universal-archs... no
checking MACHDEP... checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/opt/Python-3.7.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

具体解决方式

yum install gcc-c++ -y
    1. 编译安装
make && sudo make install
  • 5.建立软连接
    创建软连接前要是existed,就需要删除之前的链接
比如:cd /usr/bin/ 
mv python3 python3.bak 
python或者python3自行看好
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
    1. 检查版本
python -V

在这里插入图片描述

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值