5

Trying to npm install a repo i just pulled down and I got the same error as many other people:

npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

So I installed python in my wsl2 instance and restarted my shell, got the same error. So then i followed this and ran

whereis python

which outputs this:

python: /usr/bin/python3.8 /usr/bin/python3.8-config /usr/lib/python3.8 /usr/lib/python3.9 /usr/lib/python2.7 /etc/python3.8 /usr/local/lib/python3.8 /usr/include/python3.8 /mnt/c/Python39/python.exe /mnt/c/Python39/python3.dll /mnt/c/Python39/python39.dll /mnt/c/Users/ethan/AppData/Local/Microsoft/WindowsApps/python.exe /mnt/c/Users/ethan/AppData/Local/Microsoft/WindowsApps/python3.exe

so i ran

npm config set python /usr/bin/python3.8

and now when i try to install again i get a different error

npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python3.8 -c import sys; print "%s.%s.%s" % sys.version_info[:3];

and I have no idea where to go from here because apearently no one else has ever gotten this error

Bird Dad
  • 317
  • 1
  • 5
  • 14
  • I also tried ```npm config set python``` with a few of the other items that were listed in the output of ```whereis python``` but none fo them worked either – Bird Dad Sep 08 '21 at 16:15

1 Answers1

4

Same issue here.

But I installed python2.7:

sudo apt install python2

Then run:

npm config set python "/usr/bin/python2.7"

This issue solved.

nnmax
  • 71
  • 4