python - "Can' 找不到 Python 可执行文件..."- npm 安装挂起

标签 python node.js python-2.7 environment-variables

我正在使用“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=$PYTHON:/usr/bin/python
export PYTHON

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

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

关于python - "Can' 找不到 Python 可执行文件..."- npm 安装挂起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29368205/

相关文章:

javascript - 使用 npm 命令时找不到模块 'npmlog' 错误消息

Python在点击时获取鼠标x,y位置

mysql - 如何在 Mac 上的 virtualenv 上安装 mysqldb

python - PyQt 类多进程

python - Shutil.move 是否保证删除或抛出?

python - 将 h264 RTSP 流读入 p​​ython 和 opencv

python - 毫无异常(exception)地从列表中获取第一个元素

python - 有限嵌入式设备上的纪元秒到日期转换

javascript - Baconjs 永无止境的流

javascript - 您可以在构建时压缩 Angular 图像 Assets 吗?