Error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat) when running Python script
Solution 1
I got the same error and ended up using a pre-built distribution of numpy available in SourceForge (similarly, a distribution of matplotlib can be obtained).
Builds for both 32-bit 2.7 and 3.3/3.4 are available.
PyCharm detected them straight away, of course.
Solution 2
I was able to fix this on Windows 7 64-bit running Python 3.4.3 by running the set
command at a command prompt to determine the existing Visual Studio tools environment variable; in my case it was VS140COMNTOOLS
for Visual Studio Community 2015.
Then run the following (substituting the variable on the right-hand side if yours has a different name):
set VS100COMNTOOLS=%VS140COMNTOOLS%
This allowed me to install the PyCrypto module that was previously giving me the same error as the OP.
For a more permanent solution, add this environment variable to your Windows environment via Control Panel ("Edit the system environment variables"), though you might need to use the actual path instead of the variable substitution.
Solution 3
Python 3.3 and later now uses the 2010 compiler. To best way to solve the issue is to just install Visual C++ Express 2010 for free.
Now comes the harder part for 64 bit users and to be honest I just moved to 32 bit but 2010 express doesn't come with a 64 bit compiler (you get a new error, ValueError: ['path'] ) so you have to install Microsoft SDK 7.1 and follow the directions here to get the 64 bit compiler working with python: Python PIP has issues with path for MS Visual Studio 2010 Express for 64-bit install on Windows 7
It may just be easier for you to use the 32 bit version for now. In addition to getting the compiler working, you can bypass the need to compile many modules by getting the binary wheel file from this locaiton http://www.lfd.uci.edu/~gohlke/pythonlibs/
Just download the .whl file you need, shift + right click the download folder and select "open command window here" and run
pip install module-name.whl
I used that method on 64 bit 3.4.3 before I broke down and decided to just get a working compiler for pip compiles modules from source by default, which is why the binary wheel files work and having pip build from source doesn't.
People getting this (vcvarsall.bat) error on Python 2.7 can instead install "Microsoft Visual C++ Compiler for Python 2.7"
Solution 4
I have encountered this problem twice. First time I used VS 2013 and the second time I used VS 2015 with different solution. The first solution on VS 2013 and python 2.7 is:
- Click win+R
- Enter
SET VS90COMNTOOLS=%VS120COMNTOOLS%
- Close all windows
- Enter pip install again
Now, one year later, I have found an easier method to fix it. This time I use VS 2015 and python 3.4.
- Right click on My Computer.
- Click Properties
- Advanced system settings
- Environment variables
- Add New system variable
- Enter
VS100COMNTOOLS
to the variable name - Enter the value of
VS140COMNTOOLS
to the new variable. - Close all windows
Now I'm sure you will ask some question what is the VSXXXCOMNTOOLS
and what should I do if I use VS2008 or other compiler.
There is a file python\Lib\distutils\msvc9compiler.py, beginning on line 216 we see
def find_vcvarsall(version):
"""Find the vcvarsall.bat file
At first it tries to find the productdir of VS 2010 in the registry. If
that fails it falls back to the VS100COMNTOOLS env var.
"""
It means that you must give the productdir of VS 2010 for it, so if you are using python 2.x and
Visual Studio 2010 (VS10):SET VS90COMNTOOLS=%VS100COMNTOOLS%
Visual Studio 2012 (VS11):SET VS90COMNTOOLS=%VS110COMNTOOLS%
Visual Studio 2013 (VS12):SET VS90COMNTOOLS=%VS120COMNTOOLS%
Visual Studio 2015 (VS15):SET VS90COMNTOOLS=%VS140COMNTOOLS%
or if you are using python 3.x and
Visual Studio 2010 (VS10):SET VS100COMNTOOLS=%VS100COMNTOOLS%
Visual Studio 2012 (VS11):SET VS100COMNTOOLS=%VS110COMNTOOLS%
Visual Studio 2013 (VS12):SET VS100COMNTOOLS=%VS120COMNTOOLS%
Visual Studio 2015 (VS15):SET VS100COMNTOOLS=%VS140COMNTOOLS%
And it's the same as adding a new system variable. See the second ways.
Update:Sometimes,it still doesn't work.Check your path,ensure that contains VSxxxCOMNTOOLS
Solution 5
VS 2010 Express is no longer linked to any VS Express pages (that I found). I did find this link to the ISO which I used and it fixed the errors mentioned here.
http://download.microsoft.com/download/1/E/5/1E5F1C0A-0D5B-426A-A603-1798B951DDAE/VS2010Express1.iso
Note: Also make sure you have x86 everything (Python + Postgresql) or you'll get other errors. I did not try x64 everything.
Richard Knife
Updated on May 23, 2020Comments
-
Richard Knife about 4 years
Im trying to install numpy with PyCharm but i keep getting this error:
error: Microsoft Visual C++ 10.0 is required (Unable to find vcvarsall.bat).
Can someone please explain to me exactly what i have to do to fix this error(and as simple and detailed as possible)? im using python 3.4.2 (i know this has been answered before but i did not understand it).
-
camdenl over 9 yearsVisual C++ 2010 Express is free for 30 days only.
-
Hugh Perkins over 9 yearsIt's free after 30 days too; as long as you register; as far as I can tell?
-
Abdelali AHBIB about 9 yearsdidn't work for me...even if I use the whl :( [windows 7 64 bits - Python 2.7]
-
Dawid about 9 yearssame for me, when i try to install that whl i get:
lxml-3.4.4-cp34-none-win_amd64.whl is not a supported wheel on this platform.
I'm using windows 8.1 x64 with python 3.4.3 -
Muhd about 9 years@Dawid Your is python 32-bit, so use the 32bit .whl file.
-
Dawid about 9 years@Muhd you were right It was 32bit version of python but installing 32 bit package also failed for me with
lxml‑3.4.4‑cp34‑none‑win32.whl has invalid format
. The solution was: remove 32bit python, install 64bit and then install 64bit lxml package. -
Kevin almost 9 yearsI was running into the same issue because of their heavy push to Visual Studio Community Edition. I was hoping that they may have bundled old dependencies in or something, but I did not find that to be the case. Maybe this is an oversight with the win10 launch? Thanks for finding that link, it fixed the dependency issue for me.
-
Almog Cohen almost 9 yearsThe given link to VS2010 is not working anymore
-
GMzo almost 9 yearsThis is very useful. I would like to share my configure on Windows 10 64bit. I have installed python 3.4.3 32bits. There is no 'vcvarsall.bat' in my 'VS140COMNTOOLS' but it is in 'C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC' then I follow your technique. 1. Install Visual Studio 2015 Community Edition with VC++ Programming 2. Create new user variable in System Properties....Advanced....Environment Variables. It's similar this. <code> Variable name: VS100COMNTOOLS Variable value: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC
-
Charlesliam almost 9 yearsConfirmed - the links is not showing VS2010, instead VSCommunity, VSEnterprise, VSCode..what to install..I wonder
-
Sean over 8 yearsThis worked for me on Windows 10 64-bit running Python 3.4.3 64-bit using VS120COMNTOOLS (for VS 2013) instead of the 2015 variable.
-
DollarAkshay over 8 yearsThanks worked for me (Win 10 64bit with python 3.4 64 bit). I successfully installed Numpy and matplotlib
-
MuSheng over 8 yearswin10 64bit with python 3.4 32 bit,it work thanks!
-
hdorio almost 8 yearsor
export VS100COMNTOOLS=$VS140COMNTOOLS
if you use bash -
SharpCoder almost 8 yearsHow can we get it to work without installing visual studio ?
-
Gordon Mckeown almost 8 years@SharpCoder You could try using pre-compiled binaries: stackoverflow.com/questions/11405549/…
-
Bobort over 7 yearsWhy do we have to download the development kit and the whole VS software package? Why can't we just use the C++ Runtime?
-
kevinkayaks about 7 yearsThanks# @FavorMylikes-- This helped me get closer to an install, but now I get a new error about not being able to find the file c1.exe, so I added it to PATH as well, but this did not fix the issue. If you have any thoughts on this I'd be ecstatic to hear them
-
FavorMylikes about 7 yearsPlease ensure that you have a compiler with any version,for example 2010 compiler. You can download them at landinghub.visualstudio.com/visual-cpp-build-tools. After installation you could see VSxxxCOMNTOOLS in your path
-
john ktejik almost 7 years"cannot find command SET"
-
David Airapetyan about 5 yearsBeautiful hack - way better than installing the Windows SDK! Used it today when installing a Python package that used swig.exe to compile