“无法findPython可执行文件…” – npm安装挂起

我正在使用“npm install”来下载和编译我写的一个小型node.js应用程序的所有依赖项。 我使用的“package.json”文件是正确的,并包含所有需要的信息。

其中一个要安装的软件包具有“node-gyp”作为依赖项,所以我以前安装了“python2”软件包。

现在,在某个时候,我开始收到错误消息:

> node-gyp rebuild gyp ERR! configure error gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable. gyp ERR! stack at failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:103:14) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:42:11 gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:40:25) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:43:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:54:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:99:15) gyp ERR! System Linux 3.18.9-200.fc21.x86_64 gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /srv/visitor/node_modules/phantom/node_modules/dnode/node_modules/weak gyp ERR! node -v v0.12.1 gyp ERR! node-gyp -v v1.0.3 gyp ERR! not ok npm WARN optional dep failed, continuing weak@0.3.4 

问题似乎是一个环境variables缺失。

任何人都可以指向正确的方向吗? 无论我在互联网上search什么地方,都没有提到“PYTHON”variables,只有“PYTHONPATH”和其他类似的variables。 什么是解决这个问题的正确方法,以便我不会得到这些错误?

更新1:

按照这个线程的build议,我在执行“npm install”之前添加了这些命令:

 PYTHON=/usr/sbin/python2 export PYTHON 

现在我得到这个错误:

 > node-gyp rebuild gyp ERR! build error gyp ERR! stack Error: not found: make gyp ERR! stack at F (/usr/lib/node_modules/npm/node_modules/which/which.js:40:28) gyp ERR! stack at E (/usr/lib/node_modules/npm/node_modules/which/which.js:43:29) gyp ERR! stack at /usr/lib/node_modules/npm/node_modules/which/which.js:54:16 gyp ERR! stack at FSReqWrap.oncomplete (fs.js:99:15) gyp ERR! System Linux 3.18.9-200.fc21.x86_64 gyp ERR! command "node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" gyp ERR! cwd /srv/visitor/node_modules/phantom/node_modules/dnode/node_modules/weak gyp ERR! node -v v0.12.1 gyp ERR! node-gyp -v v1.0.3 gyp ERR! not ok npm WARN optional dep failed, continuing weak@0.3.4 

我觉得它说“…找不到:做…”是荒谬的。 有没有这样的可能性? 如果是的话,软件包如何正确安装?

坦率地说,我不明白一件事。 有任何想法吗?

尝试运行这个

 PYTHON=$PYTHON:/usr/bin/python export PYTHON 

把它添加到configuration文件(像~/.bash_profile等取决于你的shell),使其持久。

如果你的python没有安装在/usr/bin/python那么你可以运行which python来找出它的安装位置。

首先要做的事情是:我要感谢所有帮助我解决问题的人,尤其是@adarsh。

现在真正的问题是我错过了“make”和“gcc”。 起初,当编译器的消息提出这样的话,我发现它是荒谬的。 但请记住,这是来自Dockerregistry的PULLed图像。

我在我的Dockerfile中添加了“pacman -S – 需要–noconfirm make gcc”,并且构build过程成功完成。

不言而喻,我也需要对环境variables做出build议性的改变。

这对我有用..

 node-gyp --python C:\Users\username\.windows-build-tools\python27\python.exe build 

我们需要指向python.exe不只是到安装文件夹。

CMD

如果本地驱动器上: npm install express-generator

 #npm install express-generator -g #express --ejs . 

select是

 #y