"找不到Python可执行文件......" - npm install挂起

dsl*_*nus 9 python environment-variables node.js python-2.7

我正在使用"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
Run Code Online (Sandbox Code Playgroud)

问题似乎是缺少环境变量.

谁能指出我正确的方向?无论我在互联网上搜索什么,都没有提到"PYTHON"变量,只有"PYTHONPATH"和其他人喜欢它.解决这个问题的正确方法是什么,以便我没有得到这些错误?

更新1:

在遵循此线程的建议后,我在执行"npm install"之前添加了这些命令:

PYTHON=/usr/sbin/python2
export PYTHON
Run Code Online (Sandbox Code Playgroud)

现在我收到此错误:

> 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
Run Code Online (Sandbox Code Playgroud)

我觉得它说"......没找到:制造......"是荒谬的.它有可能是这样吗?如果是的话,如何正确安装包?

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

ada*_*rsh 6

尝试运行这个

PYTHON=$PYTHON:/usr/bin/python
export PYTHON
Run Code Online (Sandbox Code Playgroud)

将其添加到配置文件(如~/.bash_profile等,具体取决于您的 shell)以使其持久。

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


dsl*_*nus 3

首先,我要感谢所有帮助我解决问题的人,特别是@adarsh。

现在真正的问题是我缺少“make”和“gcc”。起初,当编译器消息提出这样的建议时,我发现这很荒谬。但请记住,这是从 Docker 注册表中提取的映像。

我在 Dockerfile 中添加了“pacman -S --needed --noconfirm make gcc”,构建过程成功完成。

不言而喻,我还需要对环境变量进行建议的更改。