如何在 Windows 上修复“gyp ERR!堆栈错误:找不到 Python 可执行 python”?
Posted
技术标签:
【中文标题】如何在 Windows 上修复“gyp ERR!堆栈错误:找不到 Python 可执行 python”?【英文标题】:How to fix "gyp ERR! stack Error: Can't find Python executable python" on Windows? 【发布时间】:2018-05-07 10:35:24 【问题描述】:我试图在我的 Windows 计算机上全局安装 chimp,但未能成功。这是我显示的错误。有人可以帮我解决这个问题吗?
C:\Users\Shahin>npm install -g chimp
npm WARN deprecated babel-preset-es2015@6.24.1: ???? Thanks for using Babel: we recommend using babel-preset-env now: please read babeljs.io/env to update!
npm WARN deprecated node-uuid@1.4.8: Use uuid module instead
C:\Users\Shahin\AppData\Roaming\npm\chimp -> C:\Users\Shahin\AppData\Roaming\npm\node_modules\chimp\bin\chimp.js
> fibers@1.0.15 install C:\Users\Shahin\AppData\Roaming\npm\node_modules\chimp\node_modules\fibers
> node build.js || nodejs build.js
C:\Users\Shahin\AppData\Roaming\npm\node_modules\chimp\node_modules\fibers>if not defined npm_config_node_gyp (node "C:\Users\Shahin\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release ) else (node "" rebuild --release )
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 PythonFinder.failNoPython (C:\Users\Shahin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:483:19)
gyp ERR! stack at PythonFinder.<anonymous> (C:\Users\Shahin\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at C:\Users\Shahin\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.15063
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Shahin\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd C:\Users\Shahin\AppData\Roaming\npm\node_modules\chimp\node_modules\fibers
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: `sudo apt-get install g++ build-essential`
Alpine users please run: `sudo apk add python make g++`
'nodejs' is not recognized as an internal or external command,
operable program or batch file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\chimp\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.3: wanted "os":"darwin","arch":"any" (current: "os":"win32","arch":"x64")
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers@1.0.15 install: `node build.js || nodejs build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers@1.0.15 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shahin\AppData\Roaming\npm-cache\_logs\2017-11-23T12_22_34_584Z-debug.log
我看过一些关于 ubuntu 的教程。但不知道如何为 Windows 解决这个问题。
【问题讨论】:
` 找不到 Python 可执行文件 "python" ` 让我觉得你要么没有安装 python,要么你的 python 没有在 Windows PATH 中正确配置。顺便说一句,Hi Kazi :-D 【参考方案1】:看起来您没有安装用于本地模块编译的工具链。大多数 npm 模块都是纯 js,因此您不会遇到这些问题,但有些需要在安装时编译。
安装工具链最简单的方法是使用windows-build-tools
打开管理员级别的命令提示符并运行:
npm install --global windows-build-tools
这将花费很长时间,但会安装您需要的所有内容并将其范围设置为 npm 以正确使用
【讨论】:
以上是关于如何在 Windows 上修复“gyp ERR!堆栈错误:找不到 Python 可执行 python”?的主要内容,如果未能解决你的问题,请参考以下文章
如何在 Windows 上修复 VS 2019 中的 SFML 错误?
安装了精简版的windows 的电脑如何修复?参照的程序集没有安装在系统上
如何使用 Python 2.7 在 Windows 上修复 pip 安装证书问题? [复制]
如何在 Windows 上修复“gyp ERR!堆栈错误:找不到 Python 可执行 python”?
如何在 Windows 上使用 Python 修复“from pexpect_serial import SerialSpawn”错误?