太长不看照抄版
- 查看环境
cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
- 安装新的 yum 源, 默认源已不可访问
wget http://mirrors.aliyun.com/repo/Centos-7.repo -O /etc/yum.repos.d/Centos-7-aliyun.repo
yum clean all
yum makecache
- 安装默认SCL的软件源(repository)配置文件
yum install centos-release-scl
- 修改默认SCL软件源为阿里云镜像, 默认源已不可访问
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
- 安装 gcc-9
yum install devtoolset-9
- 使用 gcc-9
基本用法
scl enable devtoolset-9 "要执行的其他命令"
这里开启 gcc-9 后, 进入新的 bash 交互环境执行其他命令
scl enable devtoolset-9 bash
conda activate my-env
pip install pandas==2.2.2
- (可选)配置当前登录用户的默认 gcc 版本, 如果系统里安装的东西很多, 这一步要谨慎.
vim ~/.bashrc
# 自动启用 SCL devtoolset-9 (GCC 9)
source /opt/rh/devtoolset-9/enable
背景
pandas / numpy 安装报错
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
直接使用系统默认安装源(如果可以访问的话,这里用了mirrors.aliyun.com镜像), gcc 版本为 4.8.5, 不满足要求
yum install gcc gcc-c++
不要把 scl enable devtoolset-9 bash 放到 .bashrc 里, 会导致嵌套循环执行