GoogleCloudPlatform / nodejs-docker

The Node.js Docker image used by Google App Engine Flexible.
https://cloud.google.com/nodejs
Apache License 2.0
405 stars 115 forks source link

Node-Gyp can't find Python 3 #228

Open selfagency opened 2 years ago

selfagency commented 2 years ago

This started happening to our builds recently:

Step #15 - "build_client": gyp info using node@16.13.2 | linux | x64
Step #15 - "build_client": gyp ERR! find Python 
Step #15 - "build_client": gyp ERR! find Python Python is not set from command line or npm configuration
Step #15 - "build_client": gyp ERR! find Python Python is not set from environment variable PYTHON
Step #15 - "build_client": gyp ERR! find Python checking if \"python3\" can be used
Step #15 - "build_client": gyp ERR! find Python - \"python3\" is not in PATH or produced an error
Step #15 - "build_client": gyp ERR! find Python checking if \"python\" can be used
Step #15 - "build_client": gyp ERR! find Python - executable path is \"/usr/bin/python\"
Step #15 - "build_client": gyp ERR! find Python - version is \"2.7.12\"
Step #15 - "build_client": gyp ERR! find Python - version is 2.7.12 - should be >=3.6.0
Step #15 - "build_client": gyp ERR! find Python - THIS VERSION OF PYTHON IS NOT SUPPORTED
Step #15 - "build_client": gyp ERR! find Python 
Step #15 - "build_client": gyp ERR! find Python **********************************************************
Step #15 - "build_client": gyp ERR! find Python You need to install the latest version of Python.
Step #15 - "build_client": gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
Step #15 - "build_client": gyp ERR! find Python you can try one of the following options:
Step #15 - "build_client": gyp ERR! find Python - Use the switch --python=\"/path/to/pythonexecutable\"
Step #15 - "build_client": gyp ERR! find Python   (accepted by both node-gyp and npm)
Step #15 - "build_client": gyp ERR! find Python - Set the environment variable PYTHON
Step #15 - "build_client": gyp ERR! find Python - Set the npm configuration variable python:
Step #15 - "build_client": gyp ERR! find Python   npm config set python \"/path/to/pythonexecutable\"
Step #15 - "build_client": gyp ERR! find Python For more information consult the documentation at:
Step #15 - "build_client": gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
Step #15 - "build_client": gyp ERR! find Python **********************************************************
Step #15 - "build_client": gyp ERR! find Python 
Step #15 - "build_client": gyp ERR! configure error 
Step #15 - "build_client": gyp ERR! stack Error: Could not find any Python installation to use
Step #15 - "build_client": gyp ERR! stack     at PythonFinder.fail (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:330:47)
Step #15 - "build_client": gyp ERR! stack     at PythonFinder.runChecks (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:159:21)
Step #15 - "build_client": gyp ERR! stack     at PythonFinder.<anonymous> (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:266:16)
Step #15 - "build_client": gyp ERR! stack     at PythonFinder.execFileCallback (/nodejs/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:297:7)
Step #15 - "build_client": gyp ERR! stack     at ChildProcess.exithandler (node:child_process:388:7)
Step #15 - "build_client": gyp ERR! stack     at ChildProcess.emit (node:events:390:28)
Step #15 - "build_client": gyp ERR! stack     at maybeClose (node:internal/child_process:1064:16)
Step #15 - "build_client": gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
Step #15 - "build_client": gyp ERR! System Linux 5.4.0-1058-gcp

I ran some checks inside the container and sure enough, there's no python3 available to the user. But...it comes standard in Ubuntu 16+. So what's up with that?

selfagency commented 2 years ago

@proppy @DominicKramer your assistance would be greatly appreciated here as well

selfagency commented 2 years ago

In case anyone else runs into this problem, I was able to get past it by adding this to the top of my Dockerfile, before FROM launcher.gcr.io/google/nodejs:

FROM ubuntu:16.04
RUN apt-get update -y
RUN apt-get install --no-install-recommends -y -q \
  apt-transport-https \
  build-essential \
  ca-certificates \
  curl \
  git \
  imagemagick \
  libkrb5-dev \
  netbase \
  python \
  python3
RUN apt-get upgrade -y
RUN apt-get clean
DrChrispoper commented 2 years ago

I am having the same issue.

DrChrispoper commented 2 years ago

I think https://github.com/GoogleCloudPlatform/nodejs-docker/pull/227 would solve the issue with Ubuntu 18.04 having python3 by default.