【发布时间】:2015-06-04 18:24:13
【问题描述】:
我正在使用“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
问题似乎是缺少环境变量。
谁能指出我正确的方向?无论我在互联网上的哪个地方搜索,都没有提到“PYTHON”变量,只有“PYTHONPATH”和其他类似的。解决此问题的正确方法是什么,以免我收到这些错误?
更新 1:
根据这个线程的建议,我在执行“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环境变量。将使用该变量中的任何内容。不管PYTHONPATH是什么。 -
@adarsh 我能说的就这么多了。你能详细说明一下吗?如果您对此做出回答,我将投票赞成。
-
您使用的是哪个操作系统?你是如何安装python2的?尝试先在命令行中执行它
-
@irqed 操作系统是 Arch Linux。该软件包是使用“pacman -S python2”安装的。由于这是 Docker 容器创建过程的一部分,因此我没有从控制台运行 python 的实用方法。
标签: python node.js python-2.7 environment-variables