Quick answer: Install Microsoft C++ Build Tools (free) with the Desktop development with C++ workload, select the MSVC v143 (or v142) toolset and the Windows 10/11 SDK, then rerun your pip install command.
I know this error is infuriating. You typed what looked like a harmless pip install, and Python suddenly wants you to compile C code like it's 2004. Here's what's actually happening: the package you're installing (or one of its dependencies) ships as a source distribution (.tar.gz) instead of a prebuilt wheel (.whl). That means pip has to compile C/C++ extensions on your machine. On Windows, the compiler it looks for is the Microsoft Visual C++ toolchain — specifically version 14.0 or newer, which maps to Visual Studio 2015 or later. If it's not there, pip throws the error and stops dead.
This trips people up constantly on packages like mysqlclient, lxml, pycrypto, python-Levenshtein, pyzmq, and uwsgi — usually because a maintainer didn't publish a wheel for your Python version (say, Python 3.12 on 64-bit Windows) yet. It also hits anyone on a fresh Windows VM or a corporate machine where the IT team never installed VS build tools.
Step-by-step fix
-
Download the Build Tools installer. Grab it from visualstudio.microsoft.com/visual-cpp-build-tools. Don't install the full Visual Studio IDE — you don't need it, and it's a 10GB+ download. The build tools installer is around 1.5GB after workload selection.
-
Run the installer and open the Workloads tab. The installer will open a Visual Studio Installer window. On the Workloads tab, check Desktop development with C++. That's the one you need.
-
Fine-tune the components on the right side. With that workload selected, confirm these are checked in the Installation details pane:
- MSVC v143 - VS 2022 C++ x64/x86 build tools (or MSVC v142 for VS 2019)
- Windows 10 SDK or Windows 11 SDK (either works)
- C++ CMake tools for Windows (only needed if the wheel uses CMake, but it's small)
If you're on Python 3.5-3.8 and some legacy package refuses to build, you may also need the v140 toolset (VS 2015). It's an optional component; add it only if v143 fails.
-
Install and wait. Expect 5-15 minutes. The installer is not fast.
-
Reboot your terminal. Close every open Command Prompt, PowerShell, and terminal window. Environment variables won't refresh in existing shells, and pip will happily keep giving you the same error from a stale session. Open a new terminal.
-
Retry the install. Bonus: add
--verboseso you can see which step failed if it still does.pip install your-package --verboseIf it succeeds, you'll see
Building wheel for ... doneinstead oferror: Microsoft Visual C++ 14.0 or greater is required.
Try a prebuilt wheel first (faster, avoids the compiler entirely)
Before installing 1.5GB of build tools, check whether a wheel already exists for your exact Python + Windows combo. Wheels are precompiled — no C++ needed.
pip install --only-binary :all: your-package
If that fails with "Could not find a version that satisfies the requirement", no wheel exists for your Python version. Two realistic escapes:
- Downgrade Python. If you're on 3.12 and a package only publishes wheels up to 3.11, install Python 3.11 in a venv just for that project. I've done this more times than I'd like to admit for
lxmlback in the day. - Grab the wheel from Christoph Gohlke's Unofficial Windows Binaries (or PyPI directly). Download the matching .whl, then
pip install path\to\file.whl. Make sure the filename matches your Python version (cp311 = CPython 3.11) and architecture (win_amd64 for 64-bit).
Alternative: use conda instead
If you're already in the Anaconda ecosystem, conda install pulls prebuilt binaries from Anaconda's channels and skips the compiler entirely. For scientific packages (numpy, scipy, pandas, scikit-learn), this is genuinely the easier path on Windows.
conda install -c conda-forge mysqlclient
For non-scientific packages, conda-forge coverage is spotty, so this isn't a universal escape hatch.
Alternative: WSL or Docker
If you're building a production service and the C-compile dance keeps biting you, stop fighting Windows. Ubuntu on WSL2 has gcc ready to go:
wsl --install -d Ubuntu
# inside WSL:
sudo apt install build-essential python3-dev
Docker works the same way — pull python:3.11, your build tools are already there. For anything server-bound, this is the real fix.
Prevention tip
Pin your dependencies with wheels-first in mind. When you set up a new Windows machine for Python dev, install the Build Tools once during setup — before you need them. It's 1.5GB and 10 minutes you'll forget about until three months later when some random package saves you the panic. Also, prefer packages that publish wheels on PyPI for your Python version; if you see .tar.gz as the only distribution, expect a compiler to be involved.
One more thing: don't chase the "Microsoft Visual C++ Redistributable" — that's a runtime library, not a compiler. It fixes missing DLL errors at app launch, not pip build failures. They look similar; they solve different problems.