python编译失败故障处理

python编译失败故障处理

make命令报错。python3部分版本中使用低版本的gcc在执行./configure带有参数–enable-optimizations导致报错,要升级gcc或者去掉–enable-optimizations参数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Could not import runpy module
Traceback (most recent call last):
File "/usr/local/src/Python-3.9.16/Lib/runpy.py", line 15, in <module>
import importlib.util
File "/usr/local/src/Python-3.9.16/Lib/importlib/util.py", line 2, in <module>
from . import abc
File "/usr/local/src/Python-3.9.16/Lib/importlib/abc.py", line 17, in <module>
from typing import Protocol, runtime_checkable
File "/usr/local/src/Python-3.9.16/Lib/typing.py", line 21, in <module>
import collections
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 `/usr/local/src/Python-3.9.16'
make: *** [profile-opt] Error 2

默认gcc版本:

1
2
3
4
5
# gcc --version
gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.