Python을 사용할 수 없음 오류로 인해 파이프라인 빌드가 실패합니다.

Python3를 설치하기 위해 exec 플러그인을 사용하는 Maven 프로젝트를 생성하여 Python 오류로 인한 파이프라인 빌드 오류를 수정합니다.

설명 description

환경

AEM as a Cloud Service

문제/증상

프론트엔드 코드에 Python이 애플리케이션을 빌드해야 하므로 Python 버전 3.10을 설치해야 합니다.

하지만 Cloud Manager에서 파이프라인을 배포할 때 빌드가 실패하고 다음 오류가 발생합니다.

[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! configure error
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack   at PythonFinder.fail (/build_root/build/<project>/ui.frontend/node_modules/node-gyp/lib/find-python.js:330:47)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at PythonFinder.runChecks (/build_root/build/<project>/ui.frontend/node_modules/node-gyp/lib/find-python.js:159:21)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/build_root/build/<project>/ui.frontend/node_modules/node-gyp/lib/find-python.js:266:16)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at PythonFinder.execFileCallback (/build_root/build/<project>/ui.frontend/node_modules/node-gyp/lib/find-python.js:297:7)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at ChildProcess.exithandler (node:child_process:317:7)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at ChildProcess.emit (node:events:365:28)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at maybeClose (node:internal/child_process:1067:16)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! stack  at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! System Linux 5.10.102.2-microsoft-standard
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! command "/build_root/build/<project>/ui.frontend/node/node" "/build_root/build/<project>/ui.frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! cwd /build_root/build/<project>/ui.frontend/node_modules/node-sass
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! node -v v16.0.0
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! node-gyp -v v8.4.1
[ Exec Stream Pumper]  [ INFO]  npm ERR! gyp ERR! not ok
[ Exec Stream Pumper]  [ INFO]  npm ERR! Build failed with error code: 1
[ Exec Stream Pumper]  [ INFO]
[ Exec Stream Pumper]  [ INFO]  npm ERR! A complete log of this run can be found in:
[ Exec Stream Pumper]  [ INFO]  npm ERR!  /root/.npm/_logs/2023-11-06T17_43_49_109Z-debug.log

Experience League 캠페인 커뮤니티에서 질문하기

이 주제에 대해 답변하고 싶은 질문이 있거나 이전 답변한 질문을 읽은 경우 이 문서를 포함하는 Experience League 커뮤니티 블로그 게시물을 보고, 질문과 의견을 보내고, Experience League 캠페인 커뮤니티에 참여하세요!

해결 방법 resolution

Python이 설치되지 않은 경우 다음 단계를 수행하여 Maven을 설치할 수 있습니다.

Python3를 설치하기 위해 exec 플러그인을 사용하는 Maven 프로젝트를 생성하려면 pom.xml에 대한 구성이 수행되어야 합니다.

예:

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>PythonInstaller</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging>
<build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>1.6.0</version><executions><execution><id>apt-get-update</id><phase>validate</phase><goals><goal>exec</goal></goals><configuration><executable>apt-get</executable><arguments><argument>update</argument></arguments></configuration></execution><execution><id>install-python3</id><phase>validate</phase><goals><goal>exec</goal></goals><configuration><executable>apt-get</executable><arguments><argument>install</argument><argument>-y</argument><argument>python3</argument></arguments></configuration></execution></executions></plugin></plugins></build></project>

Maven 구성은 Maven 빌드 라이프사이클의 유효성 검사 단계 동안 apt-get 업데이트 및 apt-get install -y python3 명령을 실행합니다. 또한 이 작업은 apt-get 명령을 사용할 수 있고 실행 중인 환경에서 빌드를 실행하는 경우에만 작동합니다. 패키지를 설치하려면 빌드에 충분한 권한이 있어야 합니다.

마찬가지로 Python 3.11을 설치해야 하는 경우 pom.xml은 다음과 같아야 합니다.

<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"><modelVersion>4.0.0</modelVersion><groupId>com.example</groupId><artifactId>PythonInstaller</artifactId><version>1.0-SNAPSHOT</version><packaging>jar</packaging>
<build><plugins><plugin><groupId>org.codehaus.mojo</groupId><artifactId>exec-maven-plugin</artifactId><version>1.6.0</version><executions><execution><id>apt-get-update</id><phase>validate</phase><goals><goal>exec</goal></goals><configuration><executable>apt-get</executable><arguments><argument>update</argument></arguments></configuration></execution><execution><id>install-python3.11</id><phase>validate</phase><goals><goal>exec</goal></goals><configuration><executable>apt-get</executable><arguments><argument>install</argument><argument>-y</argument><argument>python3.11</argument></arguments></configuration></execution></executions></plugin></plugins></build></project>
recommendation-more-help
3d58f420-19b5-47a0-a122-5c9dab55ec7f