Cannot Find Vcvarsall.Bat When Running a Python Script

error: Unable to find vcvarsall.bat when compiling Cython code

I spent hours on this, and the information was not easily findable in error: Unable to find vcvarsall.bat, that's why I post it here with the "answer your own question" feature:

  • Step 1: Install Microsoft Visual C++ Compiler for Python 2.7

  • Remark: You don't need to modify msvc9compiler.py as often suggested in many forum posts

  • Step 2: Just add import setuptools that will help Python and "Microsoft Visual C++ Compiler for Python 2.7" work together.

    import setuptools  # important
    from distutils.core import setup
    from Cython.Build import cythonize
    setup(ext_modules=cythonize("module1.pyx", build_dir="build"),
    script_args=['build'],
    options={'build':{'build_lib':'.'}})

    Note: the script_args parameter allows to run this setup.py with just python setup.py (i.e. CTRL+B in your favorite editor like Sublime Text) instead of having to pass command-line arguments like this: python setup.py build.

It works!

unable to find vcvarsall.bat error

This is a well-known problem with installing the lxml Python library on Windows.

The TL;DR version here is you install lxml from a "binary installation package" which comes pre-compiled and takes care of all the details for you.

You can find one of those here:
http://www.lfd.uci.edu/~gohlke/pythonlibs/#lxml

The 'cp' segment stands for 'C Python' (regular Python, as opposed to PyPy for example) and the version, so if you're using Python 2.7 you want one of the packages with -cp27- in the name. There are two of these, one for 32-bit and one for 64-bit. You probably want 32-bit because that's the default Python install on Windows.

Once you download the binary installation package ("wheel"), you install it using pip, e.g.:

pip install lxml‑3.6.4‑cp27‑cp27m‑win32.whl

Python Pip install Error: Unable to find vcvarsall.bat. Tried all solutions

I have tried all suggestions and found my own simple solution.

The problem is that codes written in external environment like C need compiler. Look for its own VS environment, i.e. VS 2008.

Currently my machine runs VS 2012 and faces Unable to find vcvarsall.bat.
I studied codes that i want to install to find the VS version. It was VS 2008. i have add to system variable VS90COMNTOOLS as variable name and gave the value of VS120COMNTOOLS.

You can find my step by step solution below:

  1. Right click on My Computer.
  2. Click Properties
  3. Advanced system settings
  4. Environment variables
  5. Add New system variable
  6. Enter VS90COMNTOOLS to the variable name
  7. Enter the value of current version to the new variable.
  8. Close all windows

Now open a new session and pip install your-package

vcvarsall.bat needed for python to compile missing from visual studio 2015 ( v 14)

Make sure C++ Common Tools are installed in Visual Studio.

Programs and Features -> VS 2015 -> Change

VS2015 setup



Related Topics



Leave a reply



Submit