环境

  • CentOS 7
  • gcc 4.8.5
  • Python 3.8.0

相关报错

make build_all CFLAGS_NODIST=" -fprofile-use -fprofile-correction" LDFLAGS_NODIST=""
make[1]: Entering directory `/usr/local/src/Python-3.8.0'
./python -E -S -m sysconfig --generate-posix-vars ;\
if test $? -ne 0 ; then \
	echo "generate-posix-vars failed" ; \
	rm -f ./pybuilddir.txt ; \
	exit 1 ; \
fi
Could not import runpy module
Traceback (most recent call last):
  File "/usr/local/src/Python-3.8.0/Lib/runpy.py", line 15, in <module>
    import importlib.util
  File "/usr/local/src/Python-3.8.0/Lib/importlib/util.py", line 14, in <module>
    from contextlib import contextmanager
  File "/usr/local/src/Python-3.8.0/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 `/usr/local/src/Python-3.8.0'
make: *** [profile-opt] Error 2

导致原因

  • 在低版本的gcc版本中带有 --enable-optimizations 参数时会出现上面问题
  • gcc 8.1.0修复此问题

解决方法如下

  • 1、升级gcc至8.1.0【不推荐】
  • 2、./configure参数中去掉 --enable-optimizations

转自:https://blog.csdn.net/whatday/article/details/103903955

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐