Solving "Microsoft Visual C++ 14.0 or greater is required" Error in Python
When installing Python packages that require compilation, you may encounter the error: "Microsoft Visual C++ 14.0 or greater is required." This occurs because certain Python packages contain components written in C/C++ that need to be compiled during installation.
Understanding the Error
The error indicates that your system lacks the necessary build tools to compile C/C++ code for Python packages. Many scientific, data analysis, and performance-critical Python packages rely on compiled extensions for optimal performance.
Solution 1: Install Microsoft C++ Build Tools (Recommended)
The most comprehensive solution is to install the Microsoft Visual C++ Build Tools:
- Download the Visual Studio Build Tools
- Run the installer and select "Desktop development with C++"
- Under Individual Components, ensure these are selected:
- Windows 10 SDK (or latest)
- C++ x64/x86 build tools
- MSBuild tools
Optional: Silent Installation
For automated installations, use:
vs_buildtools.exe --norestart --passive --downloadThenInstall --includeRecommended --add Microsoft.VisualStudio.Workload.NativeDesktop --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Workload.MSBuildTools
Large Download
The full installation requires approximately 5-6GB of disk space. If storage is limited, consider alternative solutions.
Solution 2: Use Pre-compiled Wheels
For systems where installing build tools isn't feasible, pre-compiled Windows wheels provide an excellent alternative:
- Visit Christoph Gohlke's Python Libraries
- Search for your required package
- Download the appropriate
.whl
file matching your Python version and architecture - Install using pip:
pip install package_name‑version‑pyversion‑none‑any.whl
Example: Installing multidict and frozenlist
# Download the appropriate .whl files first
pip install .\multidict-6.0.2-py3-none-any.whl
pip install .\frozenlist-1.3.0-py3-none-any.whl
Solution 3: Use Conda Environment
Conda often handles native dependencies automatically and includes the necessary runtime components:
# Create a new conda environment
conda create -n myenv python=3.9
conda activate myenv
# Install packages - conda may handle dependencies better
conda install package_name
Solution 4: Portable Build Tools (Limited Space)
If disk space is extremely limited, consider PortableBuildTools, which provides minimal components required for compilation.
Advanced Users Only
Portable build tools may not include all necessary components and require manual environment configuration.
Solution 5: Downgrade Python Version
Some packages may not have wheels available for the latest Python versions. Downgrading to a widely supported version (like 3.9 or 3.10) can resolve compatibility issues:
# Using conda to install older Python version
conda create -n py39 python=3.9
conda activate py39
Troubleshooting Tips
Ensure pip, wheel, and setuptools are updated:
bashpython -m pip install --upgrade pip wheel setuptools
If using conda, verify environment variables are correctly set after installing build tools
Check package-specific installation instructions, as some may have special requirements
Conclusion
The "Microsoft Visual C++ 14.0 required" error has multiple solutions depending on your constraints:
- Full capability: Install Microsoft C++ Build Tools
- Limited space: Use pre-compiled wheels from reliable sources
- Simplest approach: Use conda environments
- Compatibility: Consider downgrading Python version
For most users, installing the official Microsoft C++ Build Tools provides the most reliable long-term solution for working with Python packages requiring compilation.