Error: Can't find Python executable "python"
内容纲要

以前也经常遇到这个错误,跟node-sass相关的,这边记录一下吧
大体意思就是用到了python,然后电脑要装一下
下面是报错内容,可以看一下你的是不是也雷同

error E:\Project\product_lowcode_dem\mes3-web\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: E:\Project\product_lowcode_dem\mes3-web\node_modules\node-sass
Output:
Building: C:\Program Files\nodejs\node.exe E:\Project\product_lowcode_dem\mes3-web\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ld
flags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli   'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli   'E:\\Project\\product_lowcode_dem\\mes3-web\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli   'rebuild',
gyp verb cli   '--verbose',
gyp verb cli   '--libsass_ext=',
gyp verb cli   '--libsass_cflags=',
gyp verb cli   '--libsass_ldflags=',
gyp verb cli   '--libsass_library='
gyp verb cli ]
gyp info using node-gyp@3.8.0
gyp info using node@16.17.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:206:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:206:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` failed Error: not found: python
gyp verb `which` failed     at getNotFoundError (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:206:21)
gyp verb `which` failed  python Error: not found: python
gyp verb `which` failed     at getNotFoundError (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:13:12)
gyp verb `which` failed     at F (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:68:19)
gyp verb `which` failed     at E (E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:80:29)
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\which\which.js:89:16
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed     at E:\Project\product_lowcode_dem\mes3-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:206:21) {
gyp verb `which` failed   code: 'ENOENT'
gyp verb `which` failed }
gyp verb could not find "python". checking python launcher
gyp verb could not find "python". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
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 (E:\Project\product_lowcode_dem\mes3-web\node_modules\node-gyp\lib\configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (E:\Project\product_lowcode_dem\mes3-web\node_modules\node-gyp\lib\configure.js:509:16)
gyp ERR! stack     at callback (E:\Project\product_lowcode_dem\mes3-web\node_modules\graceful-fs\polyfills.js:299:20)
gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:206:21)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Project\\product_lowcode_dem\\mes3-web\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--
libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd E:\Project\product_lowcode_dem\mes3-web\node_modules\node-sass
gyp ERR! node -v v16.17.0

如果你的报错也是的话那就没毛病了

这里有两个解决方案,方案二极其复杂,希望你用不上

方案一

如果用npm超时,可以尝试使用yarn
附链接不谢

https://blog.csdn.net/qq_38128179/article/details/109091006

安装好 yarn 后
使用yarn安装依赖

yarn add node-sass

方案二

使用以下命令安装所需工具,最好有梯子,如果没有梯子,可以去配置一下淘宝镜像(这里不赘述了,度娘)

npm install --global --production windows-build-tools

可以看到,我在执行命令的时候,确实在占浏览的梯子

file

file

中途360等软件可能会报提醒,点击允许通过即可

异常情况

实在安装不了的情况也是有的
但是用powershell中断执行过程就会发现,其实主要是卡在VS和Python的脚本上,他其实是想依次安装这两个工具
作者这里也有解释:

https://www.npmjs.com/package/windows-build-tools

file

file

进入目录,手动安装(它不行我们就自己来装)

file

我这里装好Python后继续安装下一个 vs_BuildTools.exe

点击修改,将Nodejs勾选上安装

file

在下拉框选择修复

file

做完后再尝试 npm install
我这边是成功了….如还有问题请继续百度…..

hi,我是秋田猫,很高兴认识你,或许我们可以相互分享各自领域的”宝藏“,祝你天天开心~
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇