microsoft / node-pty

Fork pseudoterminals in Node.JS
Other
1.43k stars 232 forks source link

Python not found but it is installed #564

Closed jkutner closed 1 year ago

jkutner commented 1 year ago

Environment details

Issue description

While trying to npm install node-pty, it cannot find python:

$ /usr/bin/python --version
Python 3.8.10

$ npm install node-pty
...
npm ERR! code 1
npm ERR! path /layers/jkutner_wetty/wetty/node_modules/node-pty
npm ERR! command failed
npm ERR! command sh -c -- node scripts/install.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@9.1.0
npm ERR! gyp info using node@18.9.1 | linux | x64
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python checking Python explicitly set from NODE_GYP_FORCE_PYTHON
npm ERR! gyp ERR! find Python - process.env.NODE_GYP_FORCE_PYTHON is "/usr/bin/python"
npm ERR! gyp ERR! find Python - "/usr/bin/python" is not in PATH or produced an error
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python You need to install the latest version of Python.
npm ERR! gyp ERR! find Python Node-gyp should be able to find and use Python. If not,
npm ERR! gyp ERR! find Python you can try one of the following options:
npm ERR! gyp ERR! find Python - Use the switch --python="/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python   (accepted by both node-gyp and npm)
npm ERR! gyp ERR! find Python - Set the environment variable PYTHON
npm ERR! gyp ERR! find Python - Set the npm configuration variable python:
npm ERR! gyp ERR! find Python   npm config set python "/path/to/pythonexecutable"
npm ERR! gyp ERR! find Python For more information consult the documentation at:
npm ERR! gyp ERR! find Python https://github.com/nodejs/node-gyp#installation
npm ERR! gyp ERR! find Python **********************************************************
npm ERR! gyp ERR! find Python 
npm ERR! gyp ERR! configure error 
npm ERR! gyp ERR! stack Error: Could not find any Python installation to use
npm ERR! gyp ERR! stack     at PythonFinder.fail (/layers/jkutner_wetty/wetty/node_modules/node-gyp/lib/find-python.js:330:47)
npm ERR! gyp ERR! stack     at PythonFinder.runChecks (/layers/jkutner_wetty/wetty/node_modules/node-gyp/lib/find-python.js:159:21)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (/layers/jkutner_wetty/wetty/node_modules/node-gyp/lib/find-python.js:202:16)
npm ERR! gyp ERR! stack     at PythonFinder.execFileCallback (/layers/jkutner_wetty/wetty/node_modules/node-gyp/lib/find-python.js:294:16)
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:420:5)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1091:16)
npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:449:11)
npm ERR! gyp ERR! stack     at Socket.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:313:12)
npm ERR! gyp ERR! System Linux 5.10.104-linuxkit
npm ERR! gyp ERR! command "/layers/heroku_nodejs-engine/dist/bin/node" "/layers/jkutner_wetty/wetty/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /layers/jkutner_wetty/wetty/node_modules/node-pty
npm ERR! gyp ERR! node -v v18.9.1
npm ERR! gyp ERR! node-gyp -v v9.1.0
npm ERR! gyp ERR! not ok

What might be wrong?

daniel-brenot commented 1 year ago

If you do python --version instead of doing the full path does the command work?

Chances are that python isn't in your PATH which would be why it cant find ot.

Tyriar commented 1 year ago

Yeah this looks like an issue in your environment as node-gyp can't find Python. Following the instructions in the error or adding it to PATH manually will probably fix the problem.