背景:gitee上下载的开源vue项目,本地部署。执行【npm install】时,报错Error: Can't find Python executable "python", you can set the PYTHON env variable。
解决:
网上提供的一个解决办法:管理员身份打开cmd 键入【npm install --global --production windows-build-tools】。但是这行命令执行一半不动了,再去执行【npm install】时出现另一个问题error MSB4019: 未找到导入的项目“E:Microsoft.Cpp.Default.props”,最后参考https://github.com/felixrieseberg/windows-build-tools/issues/175解决了问题!
// 这里执行npm install -g --production windows-build-tools其实没有成功的
C:Windowssystem32>npm install -g --production windows-build-tools npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported > windows-build-tools@5.2.2 postinstall D:softjava odejs ode_global ode_moduleswindows-build-tools > node ./dist/index.js Downloading python-2.7.15.amd64.msi [> ] 0.0% (0 B/s) Downloaded python-2.7.15.amd64.msi. Saved to C:Userszhangchenxin.windows-build-toolspython-2.7.15.amd64.msi. Downloading vs_BuildTools.exe [> ] 0.0% (0 B/s) Downloaded vs_BuildTools.exe. Saved to C:Userszhangchenxin.windows-build-toolsvs_BuildTools.exe. Starting installation... Launched installers, now waiting for them to finish. This will likely take some time - please be patient! Status from the installers: ---------- Visual Studio Build Tools ---------- 2021-01-07T17:09:19 : Verbose : Spawning uninstall stub 2021-01-07T17:09:19 : Verbose : [InstallerImpl]: Rpc connection was closed. 2021-01-07T17:09:19 : Verbose : [InstallerImpl]: Stream was closed 2021-01-07T17:09:19 : Verbose : [SetupUpdaterImpl]: Rpc connection was closed. 2021-01-07T17:09:19 : Verbose : [SetupUpdaterImpl]: Stream was closed ------------------- Python -------------------- Successfully installed Python 2.7终止批处理操作吗(Y/N)? n
//这里 成功了 C:Windowssystem32>npm install --global windows-build-tools@5.0.0 npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported > windows-build-tools@5.0.0 postinstall D:softjava odejs ode_global ode_moduleswindows-build-tools > node ./dist/index.js Downloading vs_BuildTools.exe [> ] 0.0% (0 B/s) Downloaded vs_BuildTools.exe. Saved to C:Userszhangchenxin.windows-build-toolsvs_BuildTools.exe. Starting installation... Launched installers, now waiting for them to finish. This will likely take some time - please be patient! Status from the installers: ---------- Visual Studio Build Tools ---------- Successfully installed Visual Studio Build Tools. ------------------- Python -------------------- Python 2.7.15 is already installed, not installing again. Now configuring the Visual Studio Build Tools.. All done! + windows-build-tools@5.0.0 removed 1 package and updated 8 packages in 646.789s
//需要执行配置 C:Windowssystem32>npm config set msvs_version 2017 C:Windowssystem32>
注意:可能还是不能找到python,去看一下环境变量Path,有没有python27的配置,没有的话需要添加C:Usersadmin.windows-build-toolspython27
//再去执行 npm install, 成功了!