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
結語
希望點贊,收藏,評論,轉發,您的支援就是最快解救其他小夥伴的最好方法.