GCC版本
这个版本的编译器不适合编译Python3.9,在编译时会产生如下的错误。我们用这个老版本编译器编译一个新的GCC 9.2版。
Could not import runpy module
Traceback (most recent call last):File "Python-3.8.1/Lib/runpy.py", line 15, in <module>import importlib.utilFile "Python-3.8.1/Lib/importlib/util.py", line 14, in <module>from contextlib import contextmanagerFile "Python-3.8.1/Lib/contextlib.py", line 4, in <module>import _collections_abc
SystemError: <built-in function compile> returned NULL without setting an error
generate-posix-vars failed
make[1]: *** [pybuilddir.txt] Error 1
make[1]: Leaving directory `Python-3.8.1'
make: *** [profile-opt] Error 2
下载gcc
wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz
tar zxvf gcc-9.2.0.tar.xz
cd gcc-9.2.0/
编译时出现如下错误
configure: error: Building GCC requires GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+.
Try the --with-gmp, --with-mpfr and/or --with-mpc options to specify
their locations. Source code for these libraries can be found at
their respective hosting sites as well as at
ftp://gcc.gnu.org/pub/gcc/infrastructure/. See also
http://gcc.gnu.org/install/prerequisites.html for additional info. If
you obtained GMP, MPFR and/or MPC from a vendor distribution package,
make sure that you have installed both the libraries and the header
files. They may be located in separate packages.错误信息中说明,安装gcc需要这三个依赖:GMP 4.2+, MPFR 2.4.0+ and MPC 0.8.0+。错误信息,提示了下载页面的地址:ftp://gcc.gnu.org/pub/gcc/infrastructure/。打开链接:ftp://gcc.gnu.org/pub/gcc/infrastructure/。
或者 yum install gmp gmp-devel mpfr mpfr-devel libmpc libmpc-devel
找到需要的三个包地址,下载下来:
wget https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xzwget ftp://gcc.gnu.org/pub/gcc/infrastructure/gmp-6.1.0.tar.bz2wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpfr-3.1.4.tar.bz2wget ftp://gcc.gnu.org/pub/gcc/infrastructure/mpc-1.0.3.tar.gz安装GMP:
tar -jxvf gmp-6.1.0.tar.bz2
cd gmp-6.1.0
./configure
make && make install
安装MPFR:
tar -jxvf mpfr-3.1.4.tar.bz2
cd mpfr-3.1.4
./configure
make && make install
安装MPC:
tar -zxvf mpc-1.0.3.tar.gz
cd mpc-1.0.3
./configure
make && make install编译安装会出现/usr/include/gnu/stubs.h:7:27: 错误:gnu/stubs-32.h:没有那个文件或目录
yum install glibc-devel.i686
mkdir build && cd build
$ ../configure --prefix=/usr/local --disable-multilib --enable-languages=c,c++
$ make && sudo make install移除gcc
yum remove gcc