Centos 7.9 源码编译安装python 3.12报错
Centos 7.9 源码编译安装python 3.12make[1]: *** [Python/frozen_modules/codecs.h] Error 1make[1]: *** [Python/frozen_modules/_collections_abc.h] Error 1make[1]: Leaving directory `/usr/local/src/python3.12/Py
·
./_bootstrap_python ./Programs/_freeze_module.py abc ./Lib/abc.py Python/frozen_modules/abc.h
./_bootstrap_python ./Programs/_freeze_module.py codecs ./Lib/codecs.py Python/frozen_modules/codecs.h
./_bootstrap_python ./Programs/_freeze_module.py io ./Lib/io.py Python/frozen_modules/io.h
./_bootstrap_python ./Programs/_freeze_module.py _collections_abc ./Lib/_collections_abc.py Python/frozen_modules/_collections_abc.h
./_bootstrap_python ./Programs/_freeze_module.py _sitebuiltins ./Lib/_sitebuiltins.py Python/frozen_modules/_sitebuiltins.h
./_bootstrap_python ./Programs/_freeze_module.py genericpath ./Lib/genericpath.py Python/frozen_modules/genericpath.h
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
Fatal Python error: init_import_site: Failed to import the site module from _collections_abc import _check_methods
Python runtime state: initialized
SystemError: <built-in function compile> returned NULL without setting an exception
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
make[1]: *** [Python/frozen_modules/io.h] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Python/frozen_modules/abc.h] Error 1
make[1]: *** [Python/frozen_modules/genericpath.h] Error 1
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
make[1]: *** [Python/frozen_modules/_sitebuiltins.h] Error 1
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
Fatal Python error: init_import_site: Failed to import the site module
Python runtime state: initialized
Traceback (most recent call last):
File "/usr/local/src/python3.12/Python-3.12.7/Lib/site.py", line 73, in <module>
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
import os
File "/usr/local/src/python3.12/Python-3.12.7/Lib/os.py", line 29, in <module>
from _collections_abc import _check_methods
SystemError: <built-in function compile> returned NULL without setting an exception
make[1]: *** [Python/frozen_modules/codecs.h] Error 1
make[1]: *** [Python/frozen_modules/_collections_abc.h] Error 1
make[1]: Leaving directory `/usr/local/src/python3.12/Python-3.12.7'
make: *** [profile-opt] Error 2
报错如上,原因如下:
加了 --enable-optimizations参数,这个参数可以优化 python 的代码运行速度, 加上这个参数需要 gcc 版本大于等于 8.1.0,不然 make 编译会报错。
解决方法,任选其一:
方法一:升级gcc,在使用原来的命令编译
# 安装阿里云yum源
# yum -y install centos-release-scl
# cat > /etc/yum.repos.d/CentOS-SCLo-scl.repo <<'EOF'
[centos-sclo-sclo]
name=CentOS-7 - SCLo sclo
baseurl=http://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/sclo/
http://mirrors.aliyuncs.com/centos/$releasever/sclo/$basearch/sclo/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/sclo/$basearch/sclo/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
EOF
# cat > /etc/yum.repos.d/CentOS-SCLo-scl-rh.repo <<'EOF'
[centos-sclo-rh]
name=CentOS-7 - SCLo rh
baseurl=http://mirrors.aliyun.com/centos/$releasever/sclo/$basearch/rh/
http://mirrors.aliyuncs.com/centos/$releasever/sclo/$basearch/rh/
http://mirrors.cloud.aliyuncs.com/centos/$releasever/sclo/$basearch/rh/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-SIG-SCLo
EOF
# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
# echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile
# source /etc/profile
方法二: 去掉--enable-optimizations参数
# 去掉--enable-optimizations参数
# ./configure --with-openssl=/usr/local/custom-openssl --with-openssl-rpath=auto --prefix=/usr/local/python312
# make -j 8
# make altinstall
更多推荐
所有评论(0)