自学内容网 自学内容网

gyp verb check python checking for Python executable “python2.7“ in the PATH

问题

安装node-sass时即使用全局安装了windows-build-tools,还是会报错

npm ERR! code 1
npm ERR! path D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files (x86)\nodejs\node.exe D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\\Program Files (x86)\\nodejs\\node.exe',
npm ERR! gyp verb cli   'D:\\fe-easy-platform\\cms\\rongyi_ice_RYMember\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.0 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2.7" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2.7
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2.7 Error: not found: python2.7
npm ERR! gyp verb `which` failed     at getNotFoundError (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python2.7". checking python launcher
npm ERR! gyp verb could not find "python2.7". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python2.7", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at callback (D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\graceful-fs\polyfills.js:295:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files (x86)\\nodejs\\node.exe" "D:\\fe-easy-platform\\cms\\rongyi_ice_RYMember\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\fe-easy-platform\cms\rongyi_ice_RYMember\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxx\AppData\Local\npm-cache\_logs\2022-06-15T09_46_18_584Z-debug.log

方法一 失败

看到可以使用 环境变量PYTHON,于是在项目根目录下添加文件.npmrc

PYTHON=C:\Users\xxxx\.windows-build-tools\python27

最后失败
没有尝试 npm config set 的方式,也许可行

方法二 失败

在系统环境变量Path中添加上面的安装目录,添加ython27 PYTHON单独的环境变量,还是不行

方法三 成功

因为默认指向了一个固定的目录,所以使用了一个软连接 mklink /d C:\Python27 C:\Users\xxxxx\.windows-build-tools\python27,代替这个固定地址

image.png

参考

(11条消息) 从源码上解决 gyp verb check python checking for Python executable “python2.7“ in the PATH_cc_want的博客-CSDN博客
在electron中使用ffi调用C++动态库 - 简书 (jianshu.com)

最后编辑于:2024-11-11 21:07:12


喜欢的朋友记得点赞、收藏、关注哦!!!


原文地址:https://blog.csdn.net/pingguocu3/article/details/143821534

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!