centos7编译安装python3.8提示Could not import runpy module

经过搜索,在编译安装python3.8时报这个错是和gcc的版本有关,centos7默认的gcc版本时gcc4.8.5,升级到gcc8.5后问题得到解决。

在升级过程中将步骤做成了一键升级脚本,并且将相关软件包都替换成了中国的源,保证下载速度。

一键升级脚本:

#!/bin/bash

# Add the CentOS 7 EPEL repository
yum -y install epel-release

# Install the necessary packages for compiling gcc 8
yum -y install bzip2 gcc gcc-c++ make wget

# Download the gcc source code and prerequisites
cd /usr/local/src
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gcc/gcc-8.5.0/gcc-8.5.0.tar.xz
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/gmp/gmp-6.2.1.tar.xz
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpfr/mpfr-4.1.0.tar.xz
wget https://mirrors.tuna.tsinghua.edu.cn/gnu/mpc/mpc-1.2.1.tar.gz

# Extract the downloaded files
tar -xvf gcc-8.5.0.tar.xz
tar -xvf gmp-6.2.1.tar.xz
tar -xvf mpfr-4.1.0.tar.xz
tar -xvf mpc-1.2.1.tar.gz

# Rename the extracted folders to match the expected directory names
mv gmp-6.2.1 gcc-8.5.0/gmp
mv mpfr-4.1.0 gcc-8.5.0/mpfr
mv mpc-1.2.1 gcc-8.5.0/mpc

# Configure, compile and install gcc 8
cd gcc-8.5.0
./configure --disable-multilib
make -j$(nproc)
make install

# Update the default gcc and g++ to point to gcc 8
mv /usr/bin/gcc /usr/bin/gcc.old
mv /usr/bin/g++ /usr/bin/g++.old
mv /usr/bin/cc /usr/bin/cc.old
mv /usr/bin/c++ /usr/bin/c++.old
ln -s /usr/local/bin/gcc /usr/bin/gcc
ln -s /usr/local/bin/g++ /usr/bin/g++
ln -s /usr/local/bin/cc /usr/bin/cc
ln -s /usr/local/bin/c++ /usr/bin/c++

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值