Error Can‘t find Python executable “python“, you can set the PYTHON env variable.解决办法

??电脑磕坏了

最近把公司给的mac屏幕给磕坏了,换成自己的macbookpro,本来想用时间机器做个无缝衔接,结果发现不能用了,跟客服沟通被告知macos版本在11以上不支持时间机器系统迁移,只能使用迁移助理做数据备份,非常痛苦!!!要重新安装各种环境,各种软件!!!!???

???努力安装软件

安装了很多开发常用的工具,就不一一罗列了。还有各种环境配置,经过两天的时间,差不多达到了以前环境的80%,还有一些细节需要优化,工欲善其事,必先利其器。
于是我开始跑前端项目,安装完了nodejs,当我用npm i编译时,给我来了一大段报错

gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder. (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:80:29)
gyp ERR! stack     at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/which/which.js:89:16
gyp ERR! stack     at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqCallback.oncomplete (fs.js:192:21)
gyp ERR! System Darwin 21.5.0
gyp ERR! command "/usr/local/bin/node" "/Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-sass
gyp ERR! node -v v14.17.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN @babel/[email protected] requires a peer of @babel/core@^7.12.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/core@^7.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/core@^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN @babel/[email protected] requires a peer of @babel/core@^7.4.0-0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall 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!     /Users/scott/.npm/_logs/2022-06-08T09_20_09_286Z-debug.log
scott@ScottdeMacBook-Pro workflow-frontend-elem % npm install --save-dev node-sass
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.

> [email protected] install /Users/scott/project/dx_project/front_project/workflow-frontend-elem/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/darwin-x64-83_binding.node

发现一段错误提示Error: Can‘t find Python executable “python“, you can set the PYTHON env variable,这提示貌也很明显,告诉我们没有python,我在终端检查了一下果然没有。
我记得macos是自带python2.7的,于是我查阅了一下资料,发现Moterey这个版本的操作系统移出了python,需要自己去安装。好吧,认命,我装。
于是我开始使用homebrew安装python3.X。

# 命令大概是这样子
brew install python3
brew link python3

细心的我观察到报错时调用的是’python’命令,于是在.bash_profile中增加了别名配置

alias python3='/usr/bin/python3'
alias python=python3
alias python2=python3

满心欢喜继续执行npm i 进行编译项目,结果还是报错???,不过细心的我肯定会注意到这一句提示Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/darwin-x64-83_binding.node,这个node-saas从github去拉,没有拉下来。我不是已经改过了镜像源了么,于是我又查阅了一些资料。于是乎查到了一个命令。

???终极解决方案

没错,我们需要改变它的下载地址???,通过下面这个命令把下载地址改为淘宝镜像。

npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass

在这里插入图片描述

可以看到已经下载好了,这时候我们就可以正常的npm install了,所以有时候遇到问题不要慌,这个解决不了,那么就先解决下一个。???只要你跑的够快,bug就追不上你。
点赞收藏,富婆包养

先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦

你可能感兴趣的:(面试,学习路线,阿里巴巴,android,前端,后端)