Score:0

NodeJS can't find python: gyp ERR! find Python

kz flag

I'm trying to run a script but nodejs can't find python for some reason. I have tried reinstalling python, reinstalling nodejs, reinstalling my OS, running (and rebooting afterwards): export PYTHON="$(which python)", export PYTHON="$(which python3)" (which python does return the right path), npm config set python /usr/bin/python3.9, npm config set python "/usr/bin/python3.9" and export PYTHONPATH="$(which python)" but nothing has worked. I'm running 64 bit lite raspberry OS off a raspberry pi 4. I installed nodejs and python with sudo apt install python/npm/nodejs. Context

Error

The script:

#!/bin/bash

set -xe

cd client
rm -rf .next
yarn
yarn build 
cd ..

bash ./bundle-client.sh
docker build --network=host -t clipface:latest .
rm client/docker-bundle.tgz

I tried adding --python="/usr/bin/python3.9" to line 7 and 8 but it makes no difference. I can't add it to line 12 because docker doesn't have a --python switch. Line 12 is when the error occurs

Dockerfile:

FROM node:alpine

# App setup

ADD client/docker-bundle.tgz /

WORKDIR /app

RUN yarn --prod

# Configuration

ENV NODE_CONFIG_DIR=/config
ENV NODE_ENV production
ENV PORT 80
EXPOSE 80
VOLUME /clips
VOLUME /config

CMD yarn start -p ${PORT}

New errors after adding RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python to Dockerfile: https://pastebin.com/eKPZzPSk

dave_thompson_085 avatar
jp flag
Your error is happening in **docker build**. That (and docker in general) doesn't use any envvars you have set in your shell; it only uses envvars set _in Dockerfile or the (source) image_. And docker only runs software installed or mounted _in the container_ not in the host -- and at least `node:lts-alpine` (which I use) does in fact not have python, which seems like a mistake since as you've found `yarn` uses it.
kz flag
How can I fix it then? I tried adding `RUN apt-get update -y` and `RUN apt-get install -y python3` to the dockerfile but I get errors (apt-get not found) no matter where I put it. I edited the post to include the dockerfile if it's needed
kz flag
ohh I had to use `RUN apk add`. I think python might work but I get different errors now. I updated the question with the new errors but I'm not sure if I have to ask it as a new question instead
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.