Error: Microsoft Visual C++ 14.0 is required error [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 4, 2024
3 min

banner

# Error: Microsoft Visual C++ 14.0 is required error [Solved]

The error "Microsoft Visual C++ 14.0 is required" occurs when trying to pip install a module that requires you to have Microsoft Visual C++ v14.0 or greater installed.

To solve the error, download and install Microsoft Visual C++ 14.0 and rerun your pip install command.

shell
running install running build running build_py ... building 'Crypto.Random.OSRNG.winrandom' extension error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

To install Visual C++:

  1. Visit the official visualstudio.microsoft.com website and click on the Download Build Tools button.

click download build tools

  1. Start the installer and click Continue.

start installer click continue

  1. Check the Desktop development with C++ checkbox.

tick desktop development with c

  1. Click on the Install button at the bottom right corner.

click install button

  1. Wait for the installation to complete.

  2. You might get prompted to reboot your PC after the installation is complete. Click on the Restart button and try to rerun your pip install command after restarting your PC.

If the error persists or you already had Visual C++ 14.0+ installed:

  1. Click on the Search bar and then type Visual Studio Installer and start the application.

search visual studio installer

  1. Click on the Modify button at the top right corner.

click modify button

  1. Make sure the Desktop development with C++ checkbox is checked.

tick desktop development with c

  1. Click on the Modify button at the bottom right corner.

Try to issue the pip install command after making the changes.

Make sure your Visual Studio Build Tools version is up to date. Having an outdated version of Visual Studio often causes the error.

If the error persists, try to upgrade your version of the setuptools module.

# Try to upgrade your version of setuptools

Open your terminal and run the following command to upgrade setupotools.

shell
pip install setuptools --upgrade python -m install setuptools --upgrade py -m install setuptools --upgrade

Alternatively, you can use the official get-pip script to install setuptools.

Download the script from https://bootstrap.pypa.io/get-pip.py by clicking on the link, right-clicking and selecting "Save as" in your browser.

Open your terminal in the location where the get-pip.py file is downloaded and run the following command.

shell
python get-pip.py py get-pip.py

The get-pip.py script installs or upgrades pip and installs setuptools and wheel if they aren't installed already.

If the error persists, try to download and install a .whl file.

# Download and install a .whl file if you are on Windows

You can also download a suitable .whl file from the https://www.lfd.uci.edu/~gohlke/pythonlibs/ website.

First, get your Python version and check if your Python installation is 64-bit or 32-bit.

You can do that by opening CMD and typing python.

get python version and bits

For example, the screenshot shows that my Python version is 3.10 and my Python interpreter is 64-bit.

Now, click on the https://www.lfd.uci.edu/~gohlke/pythonlibs/ link, press CTRL + f and search for the name of the package.

Download the corresponding .whl file. For example, if I were trying to install the gensim package, I would download the following file.

shell
gensim‑4.2.0‑cp310‑cp310‑win_amd64.whl
The cp310 part is the version (Python 3.10) and amd64 means 64-bit.

Once you open the file, open your shell in the directory where the file is located (e.g. C:\Users\Example\Downloads) and install it using pip:

  1. Open the directory that contains the file in Explorer.
  2. Press Shift and right-click in Explorer.

windows open powershell window here

  1. Click on "Open PowerShell window here".
  2. Run the following command.
shell
pip install gensim‑4.2.0‑cp310‑cp310‑win_amd64.whl

Make sure to specify the name of the .whl file correctly as your Python version and the name of the package will likely be different.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.