缺少 python3 报错解决
# 1. 报错日志还原
Ambari 源码编译阶段遇到如下典型错误日志:
[DEBUG] Adding artifact: com.fasterxml.woodstox:woodstox-core:jar:5.4.0 with file: /root/.m2/repository/com/fasterxml/woodstox/woodstox-core/5.4.0/woodstox-core-5.4.0.jar to assembly locat
ion: var/lib/ambari-agent/cred/lib/woodstox-core-5.4.0.jar.
[DEBUG] Adding file: /root/.m2/repository/com/fasterxml/woodstox/woodstox-core/5.4.0/woodstox-core-5.4.0.jar to archive location: var/lib/ambari-agent/cred/lib/woodstox-core-5.4.0.jar
[INFO] Building tar : /opt/modules/ambari3/ambari-agent/target/ambari-agent-3.0.0.0.0.tar.gz
[INFO]
[INFO] --- exec-maven-plugin:1.2.1:exec (generate-hash-files) @ ambari-agent ---
[DEBUG] Configuring mojo org.codehaus.mojo:exec-maven-plugin:1.2.1:exec from plugin realm ClassRealm[plugin>org.codehaus.mojo:exec-maven-plugin:1.2.1, parent: jdk.internal.loader.ClassLoad
ers$AppClassLoader@30946e09]
[DEBUG] Configuring mojo 'org.codehaus.mojo:exec-maven-plugin:1.2.1:exec' with basic configurator -->
[DEBUG] (f) arguments = [../ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py, /opt/modules/ambari3/ambari-agent/target/cache/]
[DEBUG] (f) basedir = /opt/modules/ambari3/ambari-agent
[DEBUG] (f) classpathScope = runtime
[DEBUG] (f) environmentVariables = {PYTHONPATH=target/ambari-agent-3.0.0.0.0:${env.PYTHONPATH}}
[DEBUG] (f) executable = /opt/modules/ambari3/ambari-agent/../ambari-common/src/main/unix/ambari-python-wrap
[DEBUG] (f) longClasspath = false
[DEBUG] (f) project = MavenProject: org.apache.ambari:ambari-agent:3.0.0.0.0 @ /opt/modules/ambari3/ambari-agent/target/.flattened-pom.xml
[DEBUG] (f) session = org.apache.maven.execution.MavenSession@4694f70f
[DEBUG] (f) skip = false
[DEBUG] (f) workingDirectory = /opt/modules/ambari3/ambari-agent
[DEBUG] -- end configuration --
[DEBUG] Toolchains are ignored, 'executable' parameter is set to /opt/modules/ambari3/ambari-agent/../ambari-common/src/main/unix/ambari-python-wrap
[DEBUG] Executing command line: /opt/modules/ambari3/ambari-agent/../ambari-common/src/main/unix/ambari-python-wrap ../ambari-server/src/main/python/ambari_server/resourceFilesKeeper.py /o
pt/modules/ambari3/ambari-agent/target/cache/
env: ‘python3’: No such file or directory
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:01 min (Wall Clock)
[INFO] Finished at: 2025-06-05T11:16:20Z
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "replaceurl" could not be activated because it does not exist.
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (generate-hash-files) on project ambari-agent: Command execution failed. Process exited with an error: 127 (Ex
it value: 127) -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (generate-hash-files) on project ambari-agent: Command executi
on failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:215)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:840)
Caused by: org.apache.maven.plugin.MojoExecutionException: Command execution failed.
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:362)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:840)
Caused by: org.apache.commons.exec.ExecuteException: Process exited with an error: 127 (Exit value: 127)
at org.apache.commons.exec.DefaultExecutor.executeInternal (DefaultExecutor.java:377)
at org.apache.commons.exec.DefaultExecutor.execute (DefaultExecutor.java:160)
at org.codehaus.mojo.exec.ExecMojo.executeCommandLine (ExecMojo.java:610)
at org.codehaus.mojo.exec.ExecMojo.execute (ExecMojo.java:352)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:210)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:156)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute (MojoExecutor.java:148)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject (LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:196)
at org.apache.maven.lifecycle.internal.builder.multithreaded.MultiThreadedBuilder$1.call (MultiThreadedBuilder.java:186)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.Executors$RunnableAdapter.call (Executors.java:539)
at java.util.concurrent.FutureTask.run (FutureTask.java:264)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:635)
at java.lang.Thread.run (Thread.java:840)
[ERROR]
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
[root@rocky8 modules]#
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
警告
这是由于系统中未安装 python3
,导致 Ambari 调用 py 脚本的 shell 封装工具直接失败,从而整个 Maven lifecycle 中断。
# 2. 问题原因分析
- Ambari 3.x 及新版依赖大量 Python3 脚本(如 agent/server/init、资源拷贝等),而默认 Rocky8/CentOS8 有可能未自带 python3。
exec-maven-plugin
在编译阶段调用 py 脚本时,若找不到 python3 解释器,则直接抛出 127 错误码。- 此问题不局限于 Ambari,几乎所有集成 Python3 脚本的 Maven/Gradle 编译任务都可能遇到。
如果只装了 python2 环境依赖 或未做软链接,均会触发该类报错。
# 3. 一键解决方案
只需补全 python3 解释器即可修复:
dnf install -y python3
1
提示
建议始终用 dnf/yum 官方包,避免用自建软链接(如 ln -s /usr/bin/python2 /usr/bin/python),否则后续脚本兼容性难以保证。