[python] Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

I've installed Python 3.5 and while running

pip install mysql-python

it gives me the following error

error: Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat)

I have added the following lines to my Path

C:\Program Files\Python 3.5\Scripts\;
C:\Program Files\Python 3.5\;

C:\Windows\System32;
C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC;
C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC

I have a 64bit win 7 setup in my PC.

What could be the solution for mitigating this error and installing the modules correctly via pip.

This question is related to python python-3.x visual-c++

The answer is


Make sure that you've installed these required packages.Worked perfectly in my case as i installed the checked packages enter image description here


None of the solutions here and elsewhere worked for me. Turns out an incompatible 32bit version of mysqlclient is being installed on my 64bit Windows 10 OS because I'm using a 32bit version of Python

I had to uninstall my current Python 3.7 32bit, and reinstalled Python 3.7 64bit and everything is working fine now


Just had the same issue while using the latest Python 3.6. With Windows OS 10 Home Edition and 64 Bit Operation System

Steps to solve this issue :

  1. Uninstall any versions of Visual studio you have had, through Control Panel
  2. Install Visual Studio 2015 and chose the default option that will install Visual C++ 14.0 on its own
  3. You can use Pycharm for installing scrapy ->Project->Project Interpreter->+ (install scrapy)
  4. check scrapy in REPL and pycharm by import , you should not see any errors

Binary install it the simple way!

I can't believe no one has suggested this already - use the binary-only option for pip. For example, for mysqlclient:

pip install --only-binary :all: mysqlclient

Many packages don't create a build for every single release which forces your pip to build from source. If you're happy to use the latest pre-compiled binary version, use --only-binary :all: to allow pip to use an older binary version.


After reading a lot of answers in SO and none of them working, I finally managed to solve it following the steps in this thread, I will leave here the steps in case the page dissapears:

Please try to install Build Tools for Visual Studio 2017, select the workload “Visual C++ build tools” and check the options "C++/CLI support" and "VC++ 2015.3 v14.00 (v140) toolset for desktop" as below.

enter image description here

Hope it helps as it did for me.


To solve any of the following errors:

  • Failed building wheel for misaka
  • Failed to build misaka
  • Microsoft Visual C++ 14.0 is required
  • Unable to find vcvarsall.bat

The Solution is:

  1. Go to Build Tools for Visual Studio 2017

  2. Select free download under Visual Studio Community 2017. This will download the installer. Run the installer.

  3. Select what you need under workload tab:

    a. Under Windows, there are 3 choices. Only check Desktop development with C++

    b. Under Web & Cloud, there are 7 choices. Only check Python development (I believe this is optional But I have done it).

  4. In cmd, type pip3 install misaka enter image description here

Note if you already installed Visual Studio then when you run the installer, you can modify yours (click modify button under Visual Studio Community 2017) and do steps 3 and 4

Screenshot of Modify button

Final Note : If you don't want to install all modules, having the 3 ones below (or a newer version of the VC++ 2017) would be sufficient. (you can also install the Visual Studio Build Tools with only these options so you dont need to install Visual Studio Community Edition itself) => This minimal install is already a 4.5GB, so saving off anything is helpful The modules you need for c++ compiler


Your path only lists Visual Studio 11 and 12, it wants 14, which is Visual Studio 2015. If you install that, and remember to tick the box for Languages->C++ then it should work.

On my Python 3.5 install, the error message was a little more useful, and included the URL to get it from

 error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools

Edit: New working link

Edit: As suggested by Lightfire228, you may also need to upgrade setuptools package for the error to disappear:

pip install --upgrade setuptools

I had this exact issue while trying to install mayavi.

So I also had the common error: Microsoft Visual C++ 14.0 is required when pip installing a library.

Example of Error

After looking across many web pages and the solutions to this thread, with none of them working. I figured these steps (most taken from previous solutions) allowed this to work.

  1. Go to Build Tools for Visual Studio 2017 and install Build Tools for Visual Studio 2017. Which is under All downloads (scroll down) >> Tools for Visual Studio 2017
    • If you have already installed this skip to 2.

Installing Build Tools

  1. Select the C++ Components you require (I didn't know which I required so installed many of them).
    • If you have already installed Build Tools for Visual Studio 2017 then open the application Visual Studio Installer then go to Visual Studio Build Tools 2017 >> Modify >> Individual Components and selected the required components.
    • From other answers important components appear to be: C++/CLI support, VC++ 2017 version <...> latest, Visual C++ 2017 Redistributable Update, Visual C++ tools for CMake, Windows 10 SDK <...> for Desktop C++, Visual C++ Build Tools core features, Visual Studio C++ core features.

Select Components

  1. Install/Modify these components for Visual Studio Build Tools 2017.

  2. This is the important step. Open the application Visual Studio Installer then go to Visual Studio Build Tools >> Launch. Which will open a CMD window at the correct location for Microsoft Visual Studio\YYYY\BuildTools.

Open Visual Studio Installer Launch Visual Studio Build Tools CMD Build Tools Window

  1. Now enter python -m pip install --upgrade setuptools within this CMD window.

CMD Update Setuptools

  1. Finally, in this same CMD window pip install your python library: pip install -U <library>.

CMD Install Python Library


had a similar situation installing pymssql

pip was trying to build the package because there were no official wheels
for python 3.6 & windows.

solved it by downloading an unoffical wheel from here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/

specifically for your case -> http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python


TLDR run vcvars64.bat

After endlessly searching through similar questions with none of the solutions working. -Adding endless folders to my path and removing them. uninstalling and reinstalling visual studio commmunity and build tools. and step by step attempting to debug I finally found a solution that worked for me.

(background notes if anyone is in a similar situation) I recently reset my main computer and after reinstalling the newest version of python (Python3.9) libraries I used to install with no troubles (main example pip install opencv-python) gave

cl
    is not a full path and was not found in the PATH.

after adding cl to the path from C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64

and several different windows kits one at a time getting the following.

The C compiler

"C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.27.29110/bin/Hostx64/x64/cl.exe"

is not able to compile a simple test program.

with various link errors or " Run Build Command(s):jom /nologo cmTC_7c75e\fast && The system cannot find the file specified"

upgrading setuptools and wheel from both a regular command line and an admin one did nothing as well as trying to manually download a wheel or trying to install with --only-binary :all:

Finally the end result that worked for me was running the correct vcvars.bat for my python installation namely running "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat" once (not vcvarsall or vcvars32) (because my python installed was 64 bit) and then running the regular command pip install opencv-python worked.


I had the same problem. I needed a 64-bit version of Python so I installed 3.5.0 (the most recent as of writing this). After switching to 3.4.3 all of my module installations worked.

Python Releases for Windows


I had exactly the same issue and solved it by installing mysql-connector-python with:

pip install mysql-connector-python

I am on python3.7 & windows 10 and installing Microsoft Build Tools for Visual Studio 2017 (as described here) did not solve my problem that was identical to yours.


I had the same exact issue on my windows 10 python version 3.8. In my case, I needed to install mysqlclient were the error occurred Microsoft Visual C++ 14.0 is required. Because installing visual studio and it's packages could be a tedious process, Here's what I did:

step 1 - Go to unofficial python binaries from any browser and open its website.

step 2 - press ctrl+F and type whatever you want. In my case it was mysqlclient.

step 3 - Go into it and choose according to your python version and windows system. In my case it was mysqlclient-1.4.6-cp38-cp38-win32.whl and download it.

here

step 4 - open command prompt and specify the path where you downloaded your file. In my case it was C:\Users\user\Downloads

step 5 - type pip install .\mysqlclient-1.4.6-cp38-cp38-win32.whl and press enter.

Thus it was installed successfully, after which I went my project terminal re-entered the required command. This solved my problem

Note that, while working on the project in pycharm, I also tried installing mysql-client from the project interpreter. But mysql-client and mysqlclient are different things. I have no idea why and it did not work.


As the other responses pointed out, one solution is to install Visual Studio 2015. However, it takes a few GBs of disk space. One way around is to install precompiled binaries. The webpage http://www.lfd.uci.edu/~gohlke/pythonlibs (mirror) contains precompiled binaries for many Python packages. After downloading the package of interest to you, you can install it using pip install, e.g. pip install mysqlclient-1.3.10-cp35-cp35m-win_amd64.whl.


I had the exact issue while trying to install Scrapy web scraping Python framework on my Windows 10 machine. I figured out the solution this way:

  1. Download the latest (the last one) wheel file from this link wheel file for twisted package enter image description here

  2. I'd recommend saving that wheel file in the directory where you've installed Python i.e somewhere in Local Disk C

  3. Then visit the folder where the wheel file exists and run pip install <*wheel file's name*>

  4. Finally run the command pip install Scrapy again and you're good to use Scrapy or any other tool which required you to download massive Windows C++ Package/SDK.

Disclaimer: This solution worked for me while trying to install Scrapy, but I can't guarantee the same happening while installing other softwares/packages/etc.?


If you have already installed Visual Studio Build Tools (as in other comments), and upgraded setuptools but it still doesn't work:

Make sure to run pip under x86 or x64 Native Tools Command Prompt.

It can be found under VS folder in Windows start menu. The default command line prompt may NOT provide Pip the path to the VS build tool, as is in my case.


to add on top of @Sushant Chaudhary's answer

in my case, I got another error regarding lxml as below

copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-3.7\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' 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

I had to install lxml-4.2.3-cp37-cp37m-win_amd64.whl same way as in the answer of @Sushant Chaudhary to successfully complete installation of Scrapy.

  1. Download lxml-4.2.3-cp37-cp37m-win_amd64.whl from https://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml
  2. put it in folder where python is installed
  3. install it using pip install <file-name>

now you can run pip install scrapy


Just go to https://www.lfd.uci.edu/~gohlke/pythonlibs/ find your suitable package (whl file). Download it. Go to the download folder in cmd or typing 'cmd' on the address bar of the folder. Run the command :

pip install mysqlclient-1.4.6-cp38-cp38-win32.whl

(Type the file name correctly. I have given an example only). Your problem will be solved without installing build toll cpp of 6GB size.


To expand on the answers by ocean800, davidsheldon and user3661384:

You should now no longer use Visual Studio Tools 2015 since a newer version is available. As indicated by the Python documentation you should be using Visual Studio Tools 2017 instead.

Visual C++ Build Tools 2015 was upgraded by Microsoft to Build Tools for Visual Studio 2017.

Download it from here

You will require also need setuptools, if you don't have setup tools run:

pip install setuptools

Or if you already have it, be sure to upgrade it.

pip install setuptools --upgrade

For the Python documentation link above you will see that setuptools version must be at least 34.4.0. for VS Tools to work


for Python 3.7.4 following set of commands worked: Before those command, you need to confirm Desktop with C++ and Python is installed in Visual Studio.

cd "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build"
vcvarsall.bat x86_amd64
cd \
set CL=-FI"%VCINSTALLDIR%\tools\msvc\14.16.27023\include\stdint.h"


pip install pycrypto

Oops! Looks like they don't have Windows wheels on PyPI.

In the meantime, installing from source probably works or try downloading MSVC++ 14 as suggested in the error message and by others on this page.

Christoph's site also has unofficial Windows Binaries for Python Extension Packages (.whl files).

Follow steps mentioned in following links to install binaries :

  1. Directly in base python
  2. In virtual environments / Pycharm

Also check :

Which binary to download??


I had the same issue. Downloading the Build Tools for Visual Studio 2017 worked for me. Find it here


Use this link to download and install Visual C++ 2015 Build Tools. It will automatically download visualcppbuildtools_full.exe and install Visual C++ 14.0 without actually installing Visual Studio. After the installation completes, retry pip install and you won't get the error again.

I have tested it on following platform and versions:

Python 3.6 on Windows 7 64-bit
Python 3.8 on Windows 10 64-bit

I have same suggestion as a comment to the question, however, I have been requested to post this as an answer as it helped a lot of people. So I posted it as an answer.


This works for me:
pip install --only-binary :all: mysqlclient


If Visual Studio is NOT your thing, and instead you are using VS Code, then this link will guide you thru the installer to get C++ running on your Windows.

You only needs to complete the Pre-Requisites part. https://code.visualstudio.com/docs/cpp/config-msvc/#_prerequisites

This is similar with other answers, but this link will probably age better than some of the responses here.

PS: don't forget to run pip install --upgrade setuptools


Following the official installation guide for Windows C++ compilers:

https://wiki.python.org/moin/WindowsCompilers

to upgrade setuptools and install specific Microsoft Visual C++ compiler.

It has already contains some points refered in other answer.


I had the same issue while installing mysqlclient for the Django project.

In my case, it's the system architecture mismatch causing the issue. I have Windows 7 64bit version on my system. But, I had installed Python 3.7.2 32 bit version by mistake.

So, I re-installed Python interpreter (64bit) and ran the command

pip install mysqlclient

I hope this would work with other Python packages as well.


I had this same problem. A solution for updating setuptools

pip install -U setuptools

or

pip install setuptools --upgrade

Use the link to Visual C++ 2015 Build Tools. That will install Visual C++ 14.0 without installing Visual Studio.


I had the same problem when installing spaCy module. And I checked control panel I have several visual C++ redistributables installed already.

What I did was select "Microsoft Visual Studio Community 2015" which is already installed on my PC --> "Modify" -->check "Common Tools for Visual C++ 2015". Then it will take some time and download more than 1 GB to install it.

This fixed my issue. Now I have spaCy installed.


Look if the package have an official fork that include the necessary binary wheels.

I needed the package python-Levenshtein, had this error, and find the package python-Levenshtein-wheels instead.


I was facing the same problem. The following worked for me: Download the unoffical binaries file from Christoph Gohlke installers site as per the python version installed on your system. Navigate to the folder where you have installed the file and run

pip install filename

For me python_ldap-3.0.0-cp35-cp35m-win_amd64.whl worked as my machine is 64 bit and python version is 3.5. This successfully installed python-ldap on my windows machine. You can try the same for mysql-python


Examples related to python

programming a servo thru a barometer Is there a way to view two blocks of code from the same file simultaneously in Sublime Text? python variable NameError Why my regexp for hyphenated words doesn't work? Comparing a variable with a string python not working when redirecting from bash script is it possible to add colors to python output? Get Public URL for File - Google Cloud Storage - App Engine (Python) Real time face detection OpenCV, Python xlrd.biffh.XLRDError: Excel xlsx file; not supported Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation

Examples related to python-3.x

Could not load dynamic library 'cudart64_101.dll' on tensorflow CPU-only installation Replace specific text with a redacted version using Python Upgrade to python 3.8 using conda "Permission Denied" trying to run Python on Windows 10 Python: 'ModuleNotFoundError' when trying to import module from imported package What is the meaning of "Failed building wheel for X" in pip install? How to downgrade python from 3.7 to 3.6 I can't install pyaudio on Windows? How to solve "error: Microsoft Visual C++ 14.0 is required."? Iterating over arrays in Python 3 How to upgrade Python version to 3.7?

Examples related to visual-c++

How to install Visual C++ Build tools? Microsoft Visual C++ 14.0 is required (Unable to find vcvarsall.bat) How to install numpy on windows using pip install? How to use _CRT_SECURE_NO_WARNINGS How to play or open *.mp3 or *.wav sound file in c++ program? What is C# equivalent of <map> in C++? The program can't start because MSVCR110.dll is missing from your computer error LNK2038: mismatch detected for '_MSC_VER': value '1600' doesn't match value '1700' in CppFile1.obj Identifier is undefined error LNK2001: unresolved external symbol (C++)