前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >gyp ERR! stack Error: Can't find Python executable 'python'

gyp ERR! stack Error: Can't find Python executable 'python'

作者头像
szhshp
发布2022-09-21 10:20:36
1.5K0
发布2022-09-21 10:20:36
举报
文章被收录于专栏:szhshp 的第四边境中转站

gyp ERR! stack Error: Can't find Python executable 'python'

系统: Win10

Gatsby 使用一个 Starter1 进行 npm install 的时候出现问题:

代码语言:javascript
复制
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYT
HON env variable.
gyp ERR! stack     at failNoPython (G:\nodejs\node_modules\npm\node_modules\node
-gyp\lib\configure.js:101:14)
gyp ERR! stack     at G:\nodejs\node_modules\npm\node_modules\node-gyp\lib\confi
gure.js:64:11
gyp ERR! stack     at Object.oncomplete (fs.js:107:15)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "node" "G:\\nodejs\\node_modules\\npm\\node_modules\\node-gyp\\
bin\\node-gyp.js" "rebuild"
gyp ERR! cwd C:\Windows\system32\node_modules\caress-server\node_modules\buffert
ools
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok
npm ERR! buffertools@2.0.1 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the buffertools@2.0.1 install script.
npm ERR! This is most likely a problem with the buffertools package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node-gyp rebuild
npm ERR! You can get their info via:
npm ERR!     npm owner ls buffertools
npm ERR! There is likely additional logging output above.

Root Cause

Some npm plugins need node-gyp to be installed. However, node-gyp has it's own dependencies

反正就是一系列的组件没安装呗.

注意: 这玩意不支持 Python 3.0, 因此只能安装 2.7

Solution Step 1

Stackoverflow 找到的第一个答案 2:

管理员执行:

代码语言:javascript
复制
$ npm install --global --production windows-build-tools

然后执行:

代码语言:javascript
复制
$ npm install --global node-gyp

Solution Step 2

然鹅上面的 Solution 似乎对我的电脑无用啊……

可能需要手动设置 3

代码语言:javascript
复制
npm config set python python2.7
npm config set msvs_version 2015

我不确定这样的设置是否会影响到 runtime, 因此我顺手再设置了一个环境变量

PYTHON = C:\Users\Zill.windows-build-tools\python27\python.exe

注意这儿需要详细到文件名

然后就解决了

Reference


  1. https://www.gatsbyjs.org/docs/gatsby-starters/
  2. https://stackoverflow.com/questions/21365714/nodejs-error-installing-with-npm
  3. https://github.com/Microsoft/nodejs-guidelines/blob/master/windows-environment.md#compiling-native-addon-modules
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2017-11-13,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • gyp ERR! stack Error: Can't find Python executable 'python'
  • Root Cause
  • Solution Step 1
  • Solution Step 2
  • Reference
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档