尝试npm安装一个repo,我刚刚下拉,我得到了和许多其他人一样的错误:
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
所以我在wsl2实例中安装了python并重新启动了我的shell,得到了相同的错误。然后我接着执行
whereis python
输出如下:
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
所以我运行
npm config set python /usr/bin/python3.8
,现在当我试图再次安装时,我得到一个不同的错误
npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python3.8 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
,我不知道从这里去哪里,因为显然没有人得到过这个错误
这里也是一样。
但是我安装了python2.7:
sudo apt install python2
然后运行:
npm config set python "/usr/bin/python2.7"
问题解决。