Pip install says Microsoft Visual C++ is required

On Windows if installing a Python package that requires a native build the following error may result if Visual Studio Build Tools isn’t installed:

error Microsoft Visual C++ is required

Check PyPI for a prebuilt wheel compatible with your Python version and Windows architecture to avoid the need for a local build.

Otherwise, it will be necessary to build the package from source by installing Microsoft’s Build Tools for Visual Studio. In the installer, select Desktop development with C++ and include the MSVC C++ compiler and Windows SDK components for the target architecture.

Use a toolset supported by the targeted Python release and package; match the compiler architecture to the Python interpreter. Check the Python interpreter architecture like:

#!/usr/bin/env python3
import struct
import platform

print(f"Architecture: {platform.machine()}")
print(f"Pointer size: {struct.calcsize('P') * 8} bits")

Python documentation for Windows extension builds and the package’s own build instructions are the references for version-specific requirements.

C or C++ extension modules are defined in pyproject.toml by the project.