Python を使用できないというエラーにより、パイプラインのビルドに失敗します
exec プラグインを使用して Python3 をインストールする 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 をインストールできます 。
exec プラグインを使用して Python3 をインストールする 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 update および 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>