老系統(tǒng) centos7 升級(jí) gcc g++ 9

太長不看照抄版

  1. 查看環(huán)境
cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
  1. 安裝新的 yum 源, 默認(rèn)源已不可訪問

wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/Centos-7-aliyun.repo
yum clean all
yum makecache

  1. 安裝默認(rèn)SCL的軟件源(repository)配置文件

yum install centos-release-scl

  1. 修改默認(rèn)SCL軟件源為阿里云鏡像, 默認(rèn)源已不可訪問

vim /etc/yum.repos.d/CentOS-SCLo-scl.repo
修改 baseurl 配置

# CentOS-SCLo-sclo.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
# baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/sclo/
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/sclo/
mirrorlist=http://mirrorlist.centos.org?arch=$basearch&release=7&repo=sclo-sclo
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-testing]
name=CentOS-7 - SCLo sclo Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/sclo/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-source]
name=CentOS-7 - SCLo sclo Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/sclo/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-sclo-debuginfo]
name=CentOS-7 - SCLo sclo Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

vim /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo
放開 baseurl 配置行并配置新值

# CentOS-SCLo-rh.repo
#
# Please see http://wiki.centos.org/SpecialInterestGroup/SCLo for more
# information

[centos-sclo-rh]
name=CentOS-7 - SCLo rh
#baseurl=http://mirror.centos.org/centos/7/sclo/$basearch/rh/
baseurl=https://mirrors.aliyun.com/centos/7/sclo/x86_64/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-testing]
name=CentOS-7 - SCLo rh Testing
baseurl=http://buildlogs.centos.org/centos/7/sclo/$basearch/rh/
gpgcheck=0
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-source]
name=CentOS-7 - SCLo rh Sources
baseurl=http://vault.centos.org/centos/7/sclo/Source/rh/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo

[centos-sclo-rh-debuginfo]
name=CentOS-7 - SCLo rh Debuginfo
baseurl=http://debuginfo.centos.org/centos/7/sclo/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
  1. 安裝 gcc-9

yum install devtoolset-9

  1. 使用 gcc-9

基本用法
scl enable devtoolset-9 "要執(zhí)行的其他命令"

這里開啟 gcc-9 后, 進(jìn)入新的 bash 交互環(huán)境執(zhí)行其他命令
scl enable devtoolset-9 bash
conda activate my-env
pip install pandas==2.2.2

  1. (可選)配置當(dāng)前登錄用戶的默認(rèn) gcc 版本, 如果系統(tǒng)里安裝的東西很多, 這一步要謹(jǐn)慎.

vim ~/.bashrc

# 自動(dòng)啟用 SCL devtoolset-9 (GCC 9)
source /opt/rh/devtoolset-9/enable

背景

pandas / numpy 安裝報(bào)錯(cuò)

pip install pandas==2.2.2

pandas 依賴 numpy, 新版本 numpy 安裝, 依賴較新版本的 gcc g++. 其中,
numpy 2.3.4 需要 gcc g++ 版本 >=9.3
numpy 1.2.99 需要 gcc g++ 版本 >=8.4

      The Meson build system
      Version: 1.8.3
      Source dir: /tmp/pip-install-gogfvovl/numpy_e5d75fd0de8e4df19688003a5cc9b219
      Build dir: /tmp/pip-install-gogfvovl/numpy_e5d75fd0de8e4df19688003a5cc9b219/.mesonpy-5onnhylg
      Build type: native build
      Project name: NumPy
      Project version: 2.3.4
      C compiler for the host machine: cc (gcc 4.8.5 "cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
      C linker for the host machine: cc ld.bfd 2.23.52.0.1-55
      C++ compiler for the host machine: c++ (gcc 4.8.5 "c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
      C++ linker for the host machine: c++ ld.bfd 2.23.52.0.1-55
      Cython compiler for the host machine: cython (cython 3.1.6)
      Host machine cpu family: x86_64
      Host machine cpu: x86_64

      ../meson.build:28:4: ERROR: Problem encountered: NumPy requires GCC >= 9.3
      The Meson build system
      Version: 1.2.99
      Source dir: /tmp/pip-install-xbg6lehu/numpy_930d45d2bfa945bda11f489c95142db3
      Build dir: /tmp/pip-install-xbg6lehu/numpy_930d45d2bfa945bda11f489c95142db3/.mesonpy-5mszvx6t
      Build type: native build
      Project name: NumPy
      Project version: 1.26.4
      C compiler for the host machine: cc (gcc 4.8.5 "cc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
      C linker for the host machine: cc ld.bfd 2.23.52.0.1-55
      C++ compiler for the host machine: c++ (gcc 4.8.5 "c++ (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)")
      C++ linker for the host machine: c++ ld.bfd 2.23.52.0.1-55
      Cython compiler for the host machine: cython (cython 3.0.12)
      Host machine cpu family: x86_64
      Host machine cpu: x86_64

      ../meson.build:28:4: ERROR: Problem encountered: NumPy requires GCC >= 8.4

直接使用系統(tǒng)默認(rèn)安裝源(如果可以訪問的話,這里用了mirrors.aliyun.com鏡像), gcc 版本為 4.8.5, 不滿足要求

yum install gcc gcc-c++

不要把 scl enable devtoolset-9 bash 放到 .bashrc 里, 會(huì)導(dǎo)致嵌套循環(huán)執(zhí)行

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容