2022:checking for Python executable “python2” in the PATH
目录
一、node报错
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:\workspace\mall\mall-admin-web\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\workspace\mall\mall-admin-web\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\workspace\mall\mall-admin-web\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:192:21)
gyp verb `which` failed python2 Error: not found: python2
gyp verb `which` failed at getNotFoundError (E:\workspace\mall\mall-admin-web\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (E:\workspace\mall\mall-admin-web\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (E:\workspace\mall\mall-admin-web\node_modules\which\which.js:80:29)
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\which\which.js:89:16
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\isexe\index.js:42:5
gyp verb `which` failed at E:\workspace\mall\mall-admin-web\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqCallback.oncomplete (fs.js:192:21) {
gyp verb `which` failed code: 'ENOENT'
gyp verb `which` failed }
说明
1、网上常用方法一(本博主环境无效)
npm install --global --production windows-build-tools
- 这个的含义是在下载一个新的python,存放在本地目录下:C:\Users\A.windows-build-tools
- 如果你的机器没有装过python,那么这个命令有可能好使,但是,安装到这里的时候,它不会给你安装环境变量,你需要自己选择一下.
- 如果你本地装了python,有时候是无效的.
2、网上常用方法二(本博主环境无效)
-
修改本地环境变量
-
此电脑右键->属性->高级系统设置->环境变量->系统变量->path(添加本地的python路径)
*本博主这个环境的python,之前就是好使的,命令窗口输入python,是可以返回版本号的,但是使用Node时候,它还是不识别路径.
3、本博主使用方法(当前有效)
1、确保NodeJS环境安装没有问题,如果不会安装,请参考
构建工具(参考工具部署方式)
软件名称 | 版本 | 相关文章推荐 |
---|---|---|
NodeJS | 16.. | //www.cnblogs.com/liuyangfirst/p/15998172.html |
2、方法一,修改配置文件,添加python环境到Node中
- 输入命令找到node的配置文件.
npm config get userconfig
- 根据输出路径,找到本地文件位置,右键以文本格式打开.
- 添加如下的路径配置.
3、方法二,命令行添加方式,添加python环境到Node中
- 输入如下命令,在命令窗口中。
npm config set python C:\Python27\python.exe
- 输入完这个命令,本质上它会将这个替你加入到配置文件中,所以,手动还是命令方式,随你喜欢。
二、node重新加载
- 执行完上述方法,如果是项目,删除项目的node_modules文件夹,重新执行。
npm install
结语
希望点赞,收藏,评论,转发,您的支持就是最快解救其他小伙伴的最好方法.