找不到 Python 可执行文件“/path/to/executable/python2.7”,可以设置 PYTHON env 变量

Posted

技术标签:

【中文标题】找不到 Python 可执行文件“/path/to/executable/python2.7”,可以设置 PYTHON env 变量【英文标题】:Can't find Python executable "/path/to/executable/python2.7", you can set the PYTHON env variable 【发布时间】:2016-04-06 20:26:26 【问题描述】:

bufferutil@1.2.1 install /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil > node-gyp 重建 gyp 错误!配置错误gyp ERR!堆栈错误:找不到 Python 可执行文件“/path/to/executable/python2.7”,您可以设置 PYTHON 环境变量。吉普错误!堆栈在 failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR!堆栈在 /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp 错误!堆栈在 F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR!堆栈在 E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR!堆栈在 /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR!堆栈在 FSReqWrap.oncomplete (fs.js:82:15) gyp ERR!系统 Linux 3.13.0-74-generic gyp ERR!命令“/usr/bin/nodejs”“/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js”“重建”gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/bufferutil gyp ERR!节点 -v v5.3.0 gyp 错误!节点-gyp -v v3.2.1 gyp 错误!不行 npm WARN install:bufferutil@1.2.1 bufferutil@1.2.1 install:node-gyp rebuild npm WARN install:bufferutil@1.2.1 Exit status 1 > utf-8-validate@1.2.1 install /home/sudthenerd/polymer -starter-kit-1.2.1/node_modules/utf-8-validate > node-gyp 重建 gyp ERR!配置错误gyp ERR!堆栈错误:找不到 Python 可执行文件“/path/to/executable/python2.7”,您可以设置 PYTHON 环境变量。吉普错误!堆栈在 failNoPython (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:401:14) gyp ERR!堆栈在 /usr/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:330:11 gyp 错误!堆栈在 F (/usr/lib/node_modules/npm/node_modules/which/which.js:78:16) gyp ERR!堆栈在 E (/usr/lib/node_modules/npm/node_modules/which/which.js:82:29) gyp ERR!堆栈在 /usr/lib/node_modules/npm/node_modules/which/which.js:93:16 gyp ERR!堆栈在 FSReqWrap.oncomplete (fs.js:82:15) gyp ERR!系统 Linux 3.13.0-74-generic gyp ERR!命令“/usr/bin/nodejs”“/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js”“重建”gyp ERR! cwd /home/sudthenerd/polymer-starter-kit-1.2.1/node_modules/utf-8-validate gyp ERR!节点 -v v5.3.0 gyp 错误!节点-gyp -v v3.2.1 gyp 错误!不行 npm WARN install:utf-8-validate@1.2.1 utf-8-validate@1.2.1 install: node-gyp rebuild npm WARN install:utf-8-validate@1.2.1 退出状态1

【问题讨论】:

【参考方案1】:

Scott Frees 的解决方案对我不起作用,但正在运行

npm config set python $(which python)

做了。

【讨论】:

对我来说,路径略有不同。在使用 npm config 进行设置之前,请务必检查 which python 以获取路径。【参考方案2】:

如果你使用包管理器安装了 Python,它应该已经在你的路径上——但如果没有:像这样添加它:

export PATH="$PATH:/usr/local/bin/python(或任何你安装 python 的地方)

Node-gyp 需要 2.x 并且不能使用 Python3(你安装了正确的版本吗?)。

请参阅Running Python on Windows for Node.js dependencies for Windows 以确保您已设置环境变量。

【讨论】:

其实我用的是ubantu 14.04 正确 - export PATH="$PATH:/usr/local/bin/python 适用于 Linux。听起来 Python 不在您的路径上 - 无论您将它安装到何处,都需要添加到路径。【参考方案3】:

我通过将 node-sass 包升级到与我安装的 Node 版本兼容的版本解决了类似的错误。

node-sass 发布了我在他们的 NPM 页面上找到的兼容性表。

【讨论】:

以上是关于找不到 Python 可执行文件“/path/to/executable/python2.7”,可以设置 PYTHON env 变量的主要内容,如果未能解决你的问题,请参考以下文章

找不到 Python 可执行文件“python”

为啥会得到,gyp ERR!堆栈错误:找不到 Python 可执行文件“python”?

npm - “找不到 Python 可执行文件“python”,您可以设置 PYTHON 环境变量。”

未找到 xcode 13 可执行文件

text 错误:找不到Python可执行文件“python”,可以设置PYTHON env变量

从 groovy 脚本运行 gsutil:找不到 Python 可执行文件