centos7安装python3.8.12时,make报错,如何解决?

用./configure --enable-optimizations --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl --with-ssl编译了之后,
make就一直报错

img


[root@192 Python-3.8.12]# make
Running code to generate profile data (this can take a while):
# First, we need to create a clean build with profile generation
# enabled.
make profile-gen-stamp
make[1]: 进入目录“/home/GODYA/下载/Python-3.8.12”
Building with support for profile generation:
make build_all_generate_profile
make[2]: 进入目录“/home/GODYA/下载/Python-3.8.12”
make build_all CFLAGS_NODIST=" -fprofile-generate" LDFLAGS_NODIST=" -fprofile-generate" LIBS="-lcrypt -lpthread -ldl  -lutil -lm"
make[3]: 进入目录“/home/GODYA/下载/Python-3.8.12”
gcc -pthread -c -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall    -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -fprofile-generate -I./Include/internal  -I. -I./Include    -DPy_BUILD_CORE -o Programs/python.o ./Programs/python.c
/tmp/ccMjfHNh.s: Assembler messages:
/tmp/cc6TlIoA.s:12: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:12: 错误:junk at end of line, first unrecognized character is `-'
/tmp/cc6TlIoA.s:14: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:14: 错误:unknown pseudo-op: `.lvu1'
/tmp/cc6TlIoA.s:30: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:30: 错误:unknown pseudo-op: `.lvu2'
/tmp/cc6TlIoA.s:47: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:47: 错误:unknown pseudo-op: `.lvu3'
/tmp/cc6TlIoA.s:48: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:48: 错误:unknown pseudo-op: `.lvu4'
/tmp/cc6TlIoA.s:54: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:54: 错误:unknown pseudo-op: `.lvu5'
/tmp/cc6TlIoA.s:60: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:60: 错误:unknown pseudo-op: `.lvu6'
/tmp/cc6TlIoA.s:64: 错误:unknown .loc sub-directive `view'
/tmp/cc6TlIoA.s:64: 错误:unknown pseudo-op: `.lvu7'
make[3]: *** [Programs/python.o] 错误 1
make[3]: 离开目录“/home/GODYA/下载/Python-3.8.12”
make[2]: *** [build_all_generate_profile] 错误 2
make[2]: 离开目录“/home/GODYA/下载/Python-3.8.12”
make[1]: *** [profile-gen-stamp] 错误 2
make[1]: 离开目录“/home/GODYA/下载/Python-3.8.12”
make: *** [profile-run-stamp] 错误 2

我看了一下config.log,里面有如下error :
1.fatal error: ac_nonexistent.h: No such file or directory
2. fatal error: minix/config.h: No such file or directory
3. gcc: error: unrecognized command line option '-Kthread'; did you mean '-pthread'?

真心求,卡了两天了

已解决,应该是gcc版本的问题
我尝试安装其他版本的gcc:sudo yum install devtoolset-7-gcc*
使用scl enable devtoolset-7 bash激活gcc7
重新编译安装python3.8,成功

【以下回答由 GPT 生成】

首先,根据错误信息,可以看出编译时出现了一些文件找不到的错误以及一些编译选项错误。下面是解决该问题的步骤和解决方案:

  1. 缺少文件ac_nonexistent.hminix/config.h,这可能是因为缺少一些必要的开发包。可以通过以下命令安装这些包:

sudo yum install autoconf automake make gcc gcc-c++ kernel-devel

然后再次执行make命令。

  1. 关于gcc: error: unrecognized command line option '-Kthread'; did you mean '-pthread'?错误,这是由于GCC命令行选项不匹配导致的。在某些情况下,-Kthread选项被误写为-kthread或者-pthread。可以检查Makefile文件中是否存在-Kthread选项,并将其改为-pthread

  2. 对于unknown .loc sub-directive 'view'.lvuX 等错误,这可能是由于GCC版本问题。Python源代码可能不兼容您正在使用的GCC版本。您可以尝试使用更高版本的GCC编译Python。您可以使用以下命令在CentOS 7上安装最新的GCC版本:

sudo yum install centos-release-scl sudo yum install devtoolset-9

然后,在编译之前,您需要通过运行以下命令来启用GCC 9:

scl enable devtoolset-9 bash

然后进入Python源代码目录重新编译。

如果您仍然遇到其他错误,请先尝试上述解决方案,如果问题仍然存在,可能需要对Python源代码进行进一步调查或寻求更进一步的帮助。


如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^

这个安装不是一条命令不就行了