侧边栏壁纸
博主头像
运维匠博主等级

生活百般滋味,人生需要笑对

  • 累计撰写 55 篇文章
  • 累计创建 3 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

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

运维匠
2024-04-18 / 0 评论 / 0 点赞 / 48 阅读 / 3155 字
温馨提示:
本文最后更新于 2024-06-14,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

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

背景:生产环境发布前端项目报如下错误
执行npm i命令执行如下错误

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.

这提示貌也很明显,告诉我们没有python,我在终端检查了一下果然没有,于是安装python

rpm -ql python
yum install python -y

继续执行npm install,发现又有了新的错误

gyp ERR! stack Error: EACCES: permission denied, mkdir '/data/jenkins_home/workspace/gk-bms-dashboard-web-prod/node_modules/node-sass/.node-gyp'

原因分析:当前目录没有读写权限。
解决方案:编辑任务,在npm install命令后添加node-sass --unsafe-perm=true,保存任务,然后再次执行任务。

npm i node-sass --unsafe-perm=true

等待执行又报如下错误

gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/data/jenkins_home/workspace/gk-bms-dashboard-web-prod/node_modules/node-gyp/lib/build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:400:28)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
gyp ERR! System Linux 4.18.0-240.10.1.el8_3.x86_64
gyp ERR! command "/data/devtool/nodejs/bin/node" "/data/jenkins_home/workspace/gk-bms-dashboard-web-prod/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /data/jenkins_home/workspace/gk-bms-dashboard-web-prod/node_modules/node-sass
gyp ERR! node -v v14.17.5
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok 

这个错误信息表明在构建过程中遇到了问题,具体是在使用 node-gyp 编译 node-sass 时失败了。检查构建工具是否安装,gcc-c++未安装,make已经安装,接下来只需要安装rpm -ql gcc-c++

rpm -ql gcc-c++

rpm -ql make

yum install -y gcc-c++

再次执行如下:

npm i node-sass --unsafe-perm=true

一波三折,终于编译成功

评论区