[Solved-5 Solutions] Error: Unable to find vcvarsall.bat
Error Description:
- If we try to install the Python package dulwich:
- we get a cryptic error message:
- The same happens if we try installing the package manually:
Solution 1:
- For Windows installations:
While running setup.py for package installations, Python 2.7 searches for an installed Visual Studio 2008. We can trick Python to use a newer Visual Studio by setting the correct path in
VS90COMNTOOLS
environment variable before callingsetup.py
. Execute the following command based on the version of Visual Studio installed: - Visual Studio 2010 (VS10):
SET VS90COMNTOOLS=%VS100COMNTOOLS%
- Visual Studio 2012 (VS11):
SET VS90COMNTOOLS=%VS110COMNTOOLS%
- Visual Studio 2013 (VS12):
SET VS90COMNTOOLS=%VS120COMNTOOLS%
- Visual Studio 2015 (VS14):
SET VS90COMNTOOLS=%VS140COMNTOOLS%
Solution 2:
- We might have the exact same problem, and error, installing 'amara'. We have mingw32 installed, but distutils needed to be configured.
- Python 2.6 is already installed.
- Install mingw32 to
C:\programs\mingw\
- Add mingw32's bin directory to our environment variable: append
c:\programs\MinGW\bin;
to the PATH - Edit (create if not existing) distutils.cfg file located at
C:\Python26\Lib\distutils\distutils.cfg
to be:
- Now run
easy_install.exe amara.
Solution 3:
- We'll need to install a Microsoft compiler, compatible with the compiler used to build Python. This means we need Visual C++ 2008 (or newer, with some tweaking
- Microsoft now supplies a bundled compiler and headers just to be able to compile Python extensions, at the memorable URL:
Microsoft Visual C++ Compiler for Python 2.7
Solution 4:
- It all might start with this error when running setup.py install:
- The problem is that then we get a different error:
- It turns out that our anti-virus is blocking the execution of a freshly compiled .exe. We just need to disable the anti-virus "resident shield" and we might face the next error:
- This will solve it: "Either install a slightly older version of MinGW, or edit distutils\cygwinccompiler.py in Python directory to remove all instances of -mno-cygwin."
Solution 5:
- Add mingw32's bin directory to environment variable: append PATH with
C:\programs\mingw\bin;
- Create distutils.cfg located at
C:\Python27\Lib\distutils\distutils.cfg
containing:
- To deal with MinGW not recognizing the -mno-cygwin flag anymore, remove the flag in C:\Python27\Lib\distutils\cygwincompiler.py line 322 to 326, so it looks like this: