[Solved-5 Solutions] Error: Unable to find vcvarsall.bat



Error Description:

  • If we try to install the Python package dulwich:
pip install dulwich
 
click below button to copy the code. By - python tutorial - team
  • we get a cryptic error message:
error: Unable to find vcvarsall.bat
 
click below button to copy the code. By - python tutorial - team
  • The same happens if we try installing the package manually:
> python setup.py install
running build_ext
building 'dulwich._objects' extension
error: Unable to find vcvarsall.bat
 
click below button to copy the code. By - python tutorial - team

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 calling setup.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:
[build]
compiler=mingw32
 
click below button to copy the code. By - python tutorial - team
  • 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:
error: Unable to find vcvarsall.bat
 
click below button to copy the code. By - python tutorial - team
  • The problem is that then we get a different error:
configure: error: cannot run C compiled programs.
 
click below button to copy the code. By - python tutorial - team
  • 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:
cc1.exe: error: unrecognized command line option '-mno-cygwin' 
error: command 'gcc' failed with exit status 1
 
click below button to copy the code. By - python tutorial - team
  • 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:
[build]
compiler=mingw32
 
click below button to copy the code. By - python tutorial - team
  • 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:
  self.set_executables(compiler='gcc -O -Wall',
                         compiler_so='gcc -mdll -O -Wall',
                         compiler_cxx='g++ -O -Wall',
                         linker_exe='gcc',
                         linker_so='%s %s %s'
                                    % (self.linker_dll, shared_option,
                                       entry_point))
 
click below button to copy the code. By - python tutorial - team

Related Searches to Error: Unable to find vcvarsall.bat