This error usually happens when you're installing the web3
package (or a dependency like lru-dict
) and Python is trying to build a C extension, but your system doesn't have the required C++ compiler properly set up — even if you think you have the Microsoft Build Tools installed.
Here’s how to solve it step by step on Windows:
1. Install the Required C++ Build Tools (Visual C++ 14.0+)
Even if you've already installed some build tools, you may still be missing the C++ workload specifically.
Steps:
Go to: https://visualstudio.microsoft.com/visual-cpp-build-tools/
Download and run the installer.
In the installer:
Select "C++ build tools"
Ensure these components are checked:
MSVC v14.x (choose the latest)
Windows 10 or 11 SDK
C++ CMake tools for Windows
Finish installation and restart your terminal.
pip install --upgrade pip setuptools wheel
This ensures you're using versions that handle modern pyproject.toml
builds better.
If you want to avoid compiling lru-dict
yourself:
pip install lru-dict==1.1.8 --only-binary :all:
Then install web3
:
pip install web3
This may work if there's a prebuilt binary available for your system.
Sometimes dependencies clash. Run:
python -m venv web3env web3env\Scripts\activate pip install --upgrade pip pip install web3
If nothing else works, using WSL (Ubuntu on Windows) will let you avoid these Windows-specific compilation issues.
conda
EnvironmentIf you use Anaconda or Miniconda:
conda create -n web3env python=3.11 conda activate web3env pip install web3
Conda environments often resolve C dependency issues more smoothly.
If you still face problems, let me know your:
Python version (python --version
)
Pip version (pip --version
)
Exact OS version (e.g., Windows 10/11, x64?)