Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 443
Bird Dad Avatar asked Aug 09 '26 13:08

Bird Dad


1 Answers

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.

like image 86
nnmax Avatar answered Aug 12 '26 03:08

nnmax