Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python is not set from command line or npm configuration #45

Open
dilipprasad opened this issue Feb 5, 2022 · 1 comment
Open

Python is not set from command line or npm configuration #45

dilipprasad opened this issue Feb 5, 2022 · 1 comment

Comments

@dilipprasad
Copy link

Hi,

I am trying to install this in raspberry pi 4, tried via portainer got weird error, so clone the source and modified docker-compose.yaml file and build with the command specified. I am getting error, please help me here as I am a newbie.
Command dump as below
Please note I am running this as root

root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# docker buildx build \
>   --platform linux/arm/v7,linux/arm64 \
>   -f Dockerfile.arm \
>   -t snippet-box:arm .
[+] Building 0.0s (0/0)                                                                                                                           
error: multiple platforms feature is currently not supported for docker driver. Please switch to a different driver (eg. "docker buildx create --use")
root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# docker build -t snippet-box .

Sending build context to Docker daemon  2.396MB
Step 1/11 : FROM node:14-alpine
14-alpine: Pulling from library/node
5480d2ca1740: Already exists 
d4e11e4c4ec3: Extracting [================================================>  ]  34.96MB/35.76MB
4a8b4c179b91: Download complete 
829a532f5553: Download complete 
^C
root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# ls
CHANGELOG.md  Dockerfile.arm  README.md  docker-compose.yml  package-lock.json  src
Dockerfile    LICENCE.md      client     nodemon.json        package.json       tsconfig.json
root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# nano docker-compose.yml 
root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# docker build -t snippet-box .
Sending build context to Docker daemon  2.396MB
Step 1/11 : FROM node:14-alpine
14-alpine: Pulling from library/node
5480d2ca1740: Already exists 
d4e11e4c4ec3: Pull complete 
4a8b4c179b91: Pull complete 
829a532f5553: Pull complete 
Digest: sha256:9a2aa545388a135b496bd55cef2be920b96c4526c99c140170e05a8de3fce653
Status: Downloaded newer image for node:14-alpine
 ---> 95fef585e484
Step 2/11 : WORKDIR /app
 ---> Running in f16011e0236e
Removing intermediate container f16011e0236e
 ---> 263d10f59d84
Step 3/11 : COPY package*.json ./
 ---> 5a304fe3c6aa
Step 4/11 : RUN npm install
 ---> Running in 2b9fe237c454

> [email protected] install /app/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download 
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v5.0.2/napi-v3-linux-arm.tar.gz 
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (node-v83 ABI, musl) (falling back to source compile with node-gyp) 
gyp ERR! find Python 
gyp ERR! find Python Python is not set from command line or npm configuration
gyp ERR! find Python Python is not set from environment variable PYTHON
gyp ERR! find Python checking if "python" can be used
gyp ERR! find Python - "python" is not in PATH or produced an error
gyp ERR! find Python checking if "python2" can be used
gyp ERR! find Python - "python2" is not in PATH or produced an error
gyp ERR! find Python checking if "python3" can be used
gyp ERR! find Python - "python3" is not in PATH or produced an error
gyp ERR! find Python 
gyp ERR! find Python **********************************************************
gyp ERR! find Python You need to install the latest version of Python.
gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
gyp ERR! find Python you can try one of the following options:
gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
gyp ERR! find Python   (accepted by both node-gyp and npm)
gyp ERR! find Python - Set the environment variable PYTHON
gyp ERR! find Python - Set the npm configuration variable python:
gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
gyp ERR! find Python For more information consult the documentation at:
gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
gyp ERR! find Python **********************************************************
gyp ERR! find Python 
gyp ERR! configure error 
gyp ERR! stack Error: Could not find any Python installation to use
gyp ERR! stack     at PythonFinder.fail (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:307:47)
gyp ERR! stack     at PythonFinder.runChecks (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:136:21)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:179:16)
gyp ERR! stack     at PythonFinder.execFileCallback (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/find-python.js:271:16)
gyp ERR! stack     at exithandler (child_process.js:390:5)
gyp ERR! stack     at ChildProcess.errorhandler (child_process.js:402:5)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:280:12)
gyp ERR! stack     at onErrorNT (internal/child_process.js:469:16)
gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:82:21)
gyp ERR! System Linux 5.10.63-v7l+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm/node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm" "--napi_version=8" "--node_abi_napi=napi" "--napi_build_version=3" "--node_napi_label=napi-v3"
gyp ERR! cwd /app/node_modules/sqlite3
gyp ERR! node -v v14.19.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok 
node-pre-gyp ERR! build error 
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
node-pre-gyp ERR! stack     at ChildProcess.<anonymous> (/app/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:1058:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5)
node-pre-gyp ERR! System Linux 5.10.63-v7l+
node-pre-gyp ERR! command "/usr/local/bin/node" "/app/node_modules/.bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /app/node_modules/sqlite3
node-pre-gyp ERR! node -v v14.19.0
node-pre-gyp ERR! node-pre-gyp -v v0.11.0
node-pre-gyp ERR! not ok 
Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm/node_sqlite3.node --module_name=node_sqlite3 --module_path=/app/node_modules/sqlite3/lib/binding/napi-v3-linux-arm --napi_version=8 --node_abi_napi=napi --napi_build_version=3 --node_napi_label=napi-v3' (1)
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"arm"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-02-05T18_08_12_410Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 1
root@pi4nas:/home/pi/Templates/snippetbox/snippet-box# 
@danparsonson
Copy link

For anyone still facing this issue, I managed to fix it by adding the following to the top of the Dockerfile, just after FROM node:14-alpine:

ENV PYTHONUNBUFFERED=1
RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
RUN python3 -m ensurepip
RUN pip3 install --no-cache --upgrade pip setuptools

(see here for context)

If the build process hangs on

=> [ 2/11] RUN apk add --update --no-cache python3 && ln -sf python3 /usr/bin/python
=> => # fetch https://dl-cdn.alpinelinux.org/alpine/v3.17/main/x86_64/APKINDEX.tar.gz

then try modifying the build command line to include --network host, i.e.:

docker build --network host -t snippet-box:latest .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants