setuptools "Microsoft Visual C++ 14.0 or greater is required" in CI
On Windows, pip fell back to building a C extension from source and setuptools could not find an MSVC compiler. The package shipped no compatible wheel, so the build needs Visual C++ Build Tools that the runner lacks.
What this error means
On a Windows runner the build aborts with "error: Microsoft Visual C++ 14.0 or greater is required. Get it with Microsoft C++ Build Tools" while compiling a package that has a native extension.
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/Common causes
No prebuilt wheel for this Python/platform
pip could not find a Windows wheel for your interpreter, so it tried to compile from sdist, which needs a C++ toolchain.
The runner has no MSVC Build Tools
GitHub windows runners include the Visual Studio toolchain, but minimal or self-hosted Windows images may not, and the compile cannot proceed.
How to fix it
Prefer a wheel by pinning a version that ships one
- Check PyPI for a Windows wheel matching the runner Python.
- Pin to a version that publishes
*-win_amd64.whl. - Re-run so pip installs the wheel instead of compiling.
pip install --only-binary=:all: somepkgInstall the MSVC Build Tools on the runner
If you genuinely must compile, install the C++ build tools before pip.
- name: Install MSVC build tools
run: choco install visualstudio2022buildtools --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64"How to prevent it
- Prefer binary wheels over source builds on Windows CI.
- Use
--only-binaryto fail fast when no wheel exists. - Keep the runner Python aligned with versions that publish Windows wheels.