firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

12.1.0 errors with `Python is not set from command line or npm configuration`

Open k2xl opened this issue 1 year ago • 2 comments

[READ] Step 1: Are you in the right place?

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue" template.
  • For general technical questions, post a question on StackOverflow with the firebase tag.
  • For general Firebase discussion, use the firebase-talk google group.
  • For help troubleshooting your application that does not fall under one of the above categories, reach out to the personalized Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: Mac Sonoma 14.0 (23A344)
  • Firebase SDK version: 12.1.0
  • Firebase Product: admin
  • Node.js version: 20.6.1
  • NPM version: 9.8.1

[REQUIRED] Step 3: Describe the problem

Getting error when building on docker on Mac FROM node:20-alpine AS base https://github.com/sspenst/thinky.gg/pull/1101/files

Works fine on 12.0.0.

Error is below:

21.06 npm ERR! gyp info using [email protected] | linux | arm64
21.06 npm ERR! gyp ERR! find Python 
21.06 npm ERR! gyp ERR! find Python Python is not set from command line or npm configuration
21.06 npm ERR! gyp ERR! find Python Python is not set from environment variable PYTHON
21.06 npm ERR! gyp ERR! find Python checking if "python3" can be used
21.06 npm ERR! gyp ERR! find Python - executable path is ""
21.06 npm ERR! gyp ERR! find Python - "" could not be run
21.06 npm ERR! gyp ERR! find Python checking if "python" can be used
21.06 npm ERR! gyp ERR! find Python - executable path is ""
21.06 npm ERR! gyp ERR! find Python - "" could not be run
21.06 npm ERR! gyp ERR! find Python 
21.06 npm ERR! gyp ERR! find Python **********************************************************
21.06 npm ERR! gyp ERR! find Python You need to install the latest version of Python.
21.06 npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
21.06 npm ERR! gyp ERR! find Python you can try one of the following options:
21.06 npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
21.06 npm ERR! gyp ERR! find Python (accepted by both node-gyp and npm)
21.06 npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
21.06 npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
21.06 npm ERR! gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
21.06 npm ERR! gyp ERR! find Python For more information consult the documentation at:
21.06 npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
21.06 npm ERR! gyp ERR! find Python **********************************************************
21.06 npm ERR! gyp ERR! find Python 
21.06 npm ERR! gyp ERR! configure error 
21.06 npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
21.06 npm ERR! gyp ERR! stack at PythonFinder.fail (/thinky_app/node_modules/node-gyp/lib/find-python.js:306:11)
21.06 npm ERR! gyp ERR! stack at PythonFinder.findPython (/thinky_app/node_modules/node-gyp/lib/find-python.js:164:17)
21.06 npm ERR! gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
21.06 npm ERR! gyp ERR! stack at async configure (/thinky_app/node_modules/node-gyp/lib/configure.js:27:18)
21.06 npm ERR! gyp ERR! stack at async run (/thinky_app/node_modules/node-gyp/bin/node-gyp.js:81:18)
21.06 npm ERR! gyp ERR! System Linux 5.15.49-linuxkit-pr
21.06 npm ERR! gyp ERR! command "/usr/local/bin/node" "/thinky_app/node_modules/.bin/node-gyp" "rebuild"
21.06 npm ERR! gyp ERR! cwd /thinky_app/node_modules/farmhash
21.06 npm ERR! gyp ERR! node -v v20.13.1
21.06 npm ERR! gyp ERR! node-gyp -v v10.1.0
21.06 npm ERR! gyp ERR! not ok

k2xl avatar May 10 '24 01:05 k2xl

I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.

google-oss-bot avatar May 10 '24 01:05 google-oss-bot

Hi, I had a similar error with the same version of firebase admin and also on ARM. I changed my node version to 20.13 and updated my docker file by adding: RUN apk add --no-cache -u \ curl \ g++ \ automake \ autoconf \ nasm \ gcc \ gifsicle \ zlib \ git \ unzip\ make\ python3

ezequiel-imajine avatar May 10 '24 15:05 ezequiel-imajine

This should also be related to https://github.com/firebase/firebase-admin-node/pull/2534 Which you can fix by upgrading farmhash to v3.3.1. We will also include this change in the upcoming release

lahirumaramba avatar May 14 '24 18:05 lahirumaramba

I am seeing the same issue with firebase-admin v12.1.1 + farmhash v3.3.1

sspenst avatar May 22 '24 04:05 sspenst

Experiencing same here :/

mustafababil avatar May 22 '24 14:05 mustafababil

@lahirumaramba FYI, should reopen this issue

sspenst avatar May 22 '24 20:05 sspenst

Hey folks, we will look into a better fix for this. In the meantime, are you able to add python to your docker image (or https://github.com/firebase/firebase-admin-node/issues/2552#issuecomment-2104813661) to and see if that resolves the issue?

Also, see: https://github.com/lovell/farmhash/issues/48

lahirumaramba avatar May 23 '24 16:05 lahirumaramba

For others facing the same issue, it would help us if you can share more information on your environment and the errors you are seeing.

lahirumaramba avatar May 23 '24 16:05 lahirumaramba

Here is the exact error:

/var/server # npm ci
npm error code 1
npm error path /var/server/node_modules/farmhash
npm error command failed
npm error command sh -c prebuild-install || node-gyp rebuild
npm error prebuild-install warn install No prebuilt binaries found (target=3 runtime=napi arch=arm64 libc=musl platform=linux)
npm error gyp info it worked if it ends with ok
npm error gyp info using [email protected]
npm error gyp info using [email protected] | linux | arm64
npm error gyp ERR! find Python
npm error gyp ERR! find Python Python is not set from command line or npm configuration
npm error gyp ERR! find Python Python is not set from environment variable PYTHON
npm error gyp ERR! find Python checking if "python3" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python checking if "python" can be used
npm error gyp ERR! find Python - executable path is ""
npm error gyp ERR! find Python - "" could not be run
npm error gyp ERR! find Python
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python You need to install the latest version of Python.
npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm error gyp ERR! find Python you can try one of the following options:
npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm error gyp ERR! find Python (accepted by both node-gyp and npm)
npm error gyp ERR! find Python - Set the environment variable PYTHON
npm error gyp ERR! find Python - Set the npm configuration variable python:
npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
npm error gyp ERR! find Python For more information consult the documentation at:
npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm error gyp ERR! find Python **********************************************************
npm error gyp ERR! find Python
npm error gyp ERR! configure error
npm error gyp ERR! stack Error: Could not find any Python installation to use
npm error gyp ERR! stack at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:306:11)
npm error gyp ERR! stack at PythonFinder.findPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:164:17)
npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm error gyp ERR! stack at async configure (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:27:18)
npm error gyp ERR! stack at async run (/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js:81:18)
npm error gyp ERR! System Linux 6.1.0-13-arm64
npm error gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm error gyp ERR! cwd /var/server/node_modules/farmhash
npm error gyp ERR! node -v v18.20.3
npm error gyp ERR! node-gyp -v v10.1.0
npm error gyp ERR! not ok

Running inside a node:18-alpine docker container on the following environment: Linux 267451d27941 6.1.0-13-arm64 #1 SMP Debian 6.1.55-1 (2023-09-29) aarch64 Linux

Edit: Tried to update the server to 6.1.0-21-arm64, but without success. The error prevails.

** Edit 2:** Tried node:18 (no alpine) and could successfully run npm install, no building from sources or python error ✅.

lhermann avatar May 24 '24 13:05 lhermann

Thanks @lhermann for the detailed response! Would adding python build tools to your docker help? See: https://stackoverflow.com/a/59471030/1526201

How many of y'all facing this issue use the remote config API? I am wondering if we should make farmhash an optional dependency, so you would have to deal with this only if you are using the remote config API (which depends on farmhash).

lahirumaramba avatar May 24 '24 15:05 lahirumaramba

Getting a similar error using the dockerfile here: https://github.com/sspenst/thinky.gg/blob/main/Dockerfile.dev

19.32 npm error code 1
19.32 npm error path /thinky_app/node_modules/farmhash
19.32 npm error command failed
19.32 npm error command sh -c prebuild-install || node-gyp rebuild
19.32 npm error prebuild-install warn install No prebuilt binaries found (target=3 runtime=napi arch=arm64 libc=musl platform=linux)
19.32 npm error gyp info it worked if it ends with ok
19.32 npm error gyp info using [email protected]
19.32 npm error gyp info using [email protected] | linux | arm64
19.32 npm error gyp ERR! find Python 
19.32 npm error gyp ERR! find Python Python is not set from command line or npm configuration
19.32 npm error gyp ERR! find Python Python is not set from environment variable PYTHON
19.32 npm error gyp ERR! find Python checking if "python3" can be used
19.32 npm error gyp ERR! find Python - executable path is ""
19.32 npm error gyp ERR! find Python - "" could not be run
19.32 npm error gyp ERR! find Python checking if "python" can be used
19.32 npm error gyp ERR! find Python - executable path is ""
19.32 npm error gyp ERR! find Python - "" could not be run
19.32 npm error gyp ERR! find Python 
19.32 npm error gyp ERR! find Python **********************************************************
19.32 npm error gyp ERR! find Python You need to install the latest version of Python.
19.32 npm error gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
19.32 npm error gyp ERR! find Python you can try one of the following options:
19.32 npm error gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
19.32 npm error gyp ERR! find Python (accepted by both node-gyp and npm)
19.32 npm error gyp ERR! find Python - Set the environment variable PYTHON
19.32 npm error gyp ERR! find Python - Set the npm configuration variable python:
19.32 npm error gyp ERR! find Python npm config set python "/path/to/pythonexecutable"
19.32 npm error gyp ERR! find Python For more information consult the documentation at:
19.32 npm error gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
19.32 npm error gyp ERR! find Python **********************************************************
19.32 npm error gyp ERR! find Python 
19.32 npm error gyp ERR! configure error 
19.32 npm error gyp ERR! stack Error: Could not find any Python installation to use
19.32 npm error gyp ERR! stack at PythonFinder.fail (/thinky_app/node_modules/node-gyp/lib/find-python.js:306:11)
19.32 npm error gyp ERR! stack at PythonFinder.findPython (/thinky_app/node_modules/node-gyp/lib/find-python.js:164:17)
19.32 npm error gyp ERR! stack at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
19.32 npm error gyp ERR! stack at async configure (/thinky_app/node_modules/node-gyp/lib/configure.js:27:18)
19.32 npm error gyp ERR! stack at async run (/thinky_app/node_modules/node-gyp/bin/node-gyp.js:81:18)
19.32 npm error gyp ERR! System Linux 6.6.26-linuxkit
19.32 npm error gyp ERR! command "/usr/local/bin/node" "/thinky_app/node_modules/.bin/node-gyp" "rebuild"
19.32 npm error gyp ERR! cwd /thinky_app/node_modules/farmhash
19.32 npm error gyp ERR! node -v v22.2.0
19.32 npm error gyp ERR! node-gyp -v v10.1.0
19.32 npm error gyp ERR! not ok

Optional dependency could be a possible solution, we are currently only using the messaging API.

sspenst avatar May 25 '24 00:05 sspenst

Indeed same issue for me on 12.1.1

KwamsC avatar Jun 01 '24 17:06 KwamsC

@lahirumaramba my team isn't using the remote config api so that solution seems appealing (at least in our case).

This issue also occurs when using the node:20-bookworm-slim docker image as a base.

Thank you for looking into all of this, I appreciate it :)

Xhale1 avatar Jun 05 '24 01:06 Xhale1

This issue will sometimes resolve if the platform of the container is set to --platform=linux/amd64 although it can depend on your docker invocation (ex: works on a local mac build, fails on a github container build)

Setting the platform to amd64 allows for the prebuilt binary of farmhash to be fetched

carusooo avatar Jun 10 '24 22:06 carusooo

If making farmhash optional, I'd be all for that as my project does not use the remote config API. Alternatively, I can confirm that if I install python before installing the dependencies, it works as intended. It does increase my docker image quite a bit so for now I just downgraded firebase-admin to 12.0.0

Thanks for looking into this!

razvanilin avatar Jun 11 '24 03:06 razvanilin

Thanks for the additional context folks! We are also looking into switching to an alternative dependency https://www.npmjs.com/package/farmhash-modern that does not require python. Let me run some tests with that as that seem to be a better option...

lahirumaramba avatar Jun 11 '24 15:06 lahirumaramba

Do we have an update on this?

I am seeing lots of merges on this, but still facing the issue. I have tried almost everything, installing python, adding PATH, node-gyp build with python. but nothing seems to work.

The critical problem on my end is that my setup is using [email protected] for sending multi-cast messages for push notifications. Now upgrading it to 12 directly is a problem. Can anyone tell of a safe version, where I can shift without much hassle.

Any help would be appreciated.

hdr-js avatar Jun 18 '24 14:06 hdr-js

If you are experiencing issues installing firebase-admin, you can try downgrading to [email protected].

Environment:

OS: Windows, macOS (Linux might work too) Node version: 18+

Reason: The issue is related to the farmhash dependency, which requires Python and node-gyp.

chandrasekhar2039 avatar Jun 18 '24 18:06 chandrasekhar2039

Hey folks, we replaced farmhash with farmhash-modern in v12.2.0. Please test with the latest firebase-admin v12.2.0 and let us know if you run into any issues. Thanks!

lahirumaramba avatar Jun 20 '24 19:06 lahirumaramba

works well on docker build with bun:1.1.13-alpine

SnowMarble avatar Jun 21 '24 01:06 SnowMarble

Hi @lahirumaramba , Can you elaborate what you did exactly? the farmhash is used under the hood right by firebase-admin, how did you replace it? THanks

hassanzadeh avatar Sep 16 '24 03:09 hassanzadeh