La generazione della pipeline non riesce a causa di un errore di Python non disponibile
Correggi l’errore di creazione della pipeline a causa di un errore Python creando un progetto Maven che utilizza il plug-in exec per installare Python3.
Descrizione description
Ambiente
AEM as a Cloud Service
Problema/Sintomi
È necessario installare Python versione 3.10 in quanto il codice front-end richiede Python per generare l’applicazione.
Tuttavia, quando si distribuisce la pipeline in Cloud Manager, la build non riesce e viene visualizzato il seguente errore:
[ 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
Poni Domande Nella Community Di Experience League Campaign
In caso di domande a cui vorresti avere risposto su questo argomento o leggere le precedenti risposte alle domande, ti invitiamo a visualizzare il nostro post di blog della community di Experienci League che include questo articolo, a inviarci le tue domande e i tuoi commenti e a partecipare alla community di Experienci League Campaign.
Risoluzione resolution
Se Python non è installato, Maven può essere installato seguendo la procedura seguente.
Per creare un progetto Maven che utilizza il plug-in exec per installare Python3, è necessario configurare un file pom.xml.
Esempio:
<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>
La configurazione Maven eseguirà i comandi apt-get e apt-get install -y python3 durante la fase di convalida del ciclo di vita della build Maven. Inoltre, questo funzionerà solo se la build viene eseguita in un ambiente in cui il comando apt-get è disponibile ed in esecuzione. La build deve disporre di autorizzazioni sufficienti per installare i pacchetti.
Analogamente, se è necessario installare Python 3.11, il file pom.xml avrà un aspetto simile al seguente:
<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>