2022:checking for Python executable "python2" in the PATH
阿新 • • 發佈:2022-03-17
目錄
一、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.. | https://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
結語
希望點贊,收藏,評論,轉發,您的支援就是最快解救其他小夥伴的最好方法.