在 Windows 上用 pip 安装部分包时,如果缺少 C++ 编译环境,会报如下错误:
1 | error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ |
网上能找到的不少教程已经过期了。目前亲测有效的办法很简单:直接打开错误提示里的链接。
安装步骤
- 访问 Microsoft C++ Build Tools
- 下载 Download Build Tools 并运行安装程序
- 在工作负载里勾选 Windows → Desktop development with C++
- 确认安装,等待完成
装好之后重新 pip install,一般就能正常编译安装了。