Pipeline Build fails due to Python not available error

Fix the Pipeline Build failure due to a Python error by creating a Maven project that uses the exec plugin to install Python3.

Description description

Environment

AEM as a Cloud Service

Issue/Symptoms

Python version 3.10 must be installed as the frontend code requires Python to build the application.

However, when deploying the pipeline in Cloud Manager, the build fails with the following error:

[ 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

Resolution resolution

If Python is not installed, Maven can be installed by following these steps.

To create a Maven Project that uses the exec plugin to install Python3, a configuration to a pom.xml must be done.

Example:

<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>

The Maven configuration will run the apt-get update and apt-get install -y python3 commands during the validate phase of the Maven build lifecycle. Also, note that this will only work if the build is run in an environment where the apt-get command is available and running. The build needs to have sufficient permissions to install packages.

Similarly, if you need to install Python 3.11, the pom.xml should look like:

**``` <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"> 4.0.0 com.example PythonInstaller 1.0-SNAPSHOT jar

<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>
```**

+-----------------------------------+
| Target Insertion                  |
+==========================+========+
| recommendation-more-help |        |
+--------------------------+--------+

---

+--------------------------------------+
| Toc                                  |
+======================================+
| 3d58f420-19b5-47a0-a122-5c9dab55ec7f |
+--------------------------------------+

---

+-------------+
| Doc Actions |
+=============+
|             |
+-------------+

+----------+
| Mini Toc |
+==========+
|          |
+----------+

+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Metadata                                                                                                                                                                  |
+==========================+================================================================================================================================================+
| id                       | 654d1f3ebef8e626228572df                                                                                                                       |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| coveo-solution           | Experience Manager                                                                                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| applies-to               | Experience Manager                                                                                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| article-created-by       | Zita Rodricks                                                                                                                                  |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| article-created-date     | 12/5/2023 2:08:58 PM                                                                                                                           |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| article-number           | KA-23141                                                                                                                                       |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| article-published-by     | Zita Rodricks                                                                                                                                  |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| article-published-date   | 12/5/2023 2:09:55 PM                                                                                                                           |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| breadcrumb-url           | /docs/experience-cloud-kcs/kbarticles/KA-08979.html                                                                                            |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| bug                      | False                                                                                                                                          |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| cloud                    | Experience Cloud, Document Cloud                                                                                                               |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| coveo-content-type       | Troubleshooting                                                                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| description              | Learn how to fix Pipeline Build failure due to a Python error.                                                                                 |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| dynamics-url             | https\://adobe-ent.crm.dynamics.com/main.aspx?forceUCI=1\&pagetype=entityrecord\&etn=knowledgearticle\&id=f6d8ccd1-7793-ee11-be37-6045bd0061cb |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| exl-id                   | 5e3a2c97-0709-43ef-b189-9b7d3e3a6673                                                                                                           |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-commit               | e531ee91fffc14d4f3de219d5dc1ae19f887825f                                                                                                       |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-commit-file          |                                                                                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-edit                 | https\://github.com/AdobeDocs/experience-cloud-kcs.en/tree/master/articles/KA-23141.md                                                         |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-filename             | /articles/KA-23141.md                                                                                                                          |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-issue                | https\://github.com/AdobeDocs/experience-cloud-kcs.en/issues/new                                                                               |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| git-repo                 | https\://github.com/AdobeDocs/experience-cloud-kcs.en                                                                                          |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| index                    | true                                                                                                                                           |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| internal-notes           | None                                                                                                                                           |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| keywords                 | KCS,Pipeline Build Fail,Python Error,Maven Plugin                                                                                              |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| landing-page-description | Learn how to fix Pipeline Build failure due to a Python error.                                                                                 |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| last-update              | Wed Dec 06 2023 00:00:00 GMT\+0000 (Coordinated Universal Time)                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| next-page                | /docs/experience-cloud-kcs/kbarticles/KA-16763.html                                                                                            |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| original-solution        | Experience Manager                                                                                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| pipeline\_filename       | /articles/KA-23141.md                                                                                                                          |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| pipeline\_internal       | false                                                                                                                                          |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| prev-page                | /docs/experience-cloud-kcs/kbarticles/KA-21682.html                                                                                            |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| product                  | Experience Manager                                                                                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| publish-url              | https\://experienceleague.adobe.com/docs/experience-cloud-kcs/kbarticles/KA-23141.html?lang=en                                                 |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| resolution               | Resolution                                                                                                                                     |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| solution                 | Experience Manager                                                                                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| solution-title           | Troubleshooting                                                                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| title                    | Pipeline Build fails due to Python not available error \| Adobe Experience Manager                                                             |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| type                     | Troubleshooting                                                                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| version-number           | 4                                                                                                                                              |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| build-date               | Fri May 24 2024 23:16:59 GMT\+0000 (Coordinated Universal Time)                                                                                |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+
| breadcrumbs              | \[{"title":"Documentation","url":"/docs/"},{"title":"Pipeline Build fails due to Python not available error","url":""}]                        |
+--------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+