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 postsStep 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 justpython 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:
- Right click on My Computer.
- Click Properties
- Advanced system settings
- Environment variables
- Add New system variable
- Enter VS90COMNTOOLS to the variable name
- Enter the value of current version to the new variable.
- 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
Related Topics
Check If a File Is Not Open Nor Being Used by Another Process
How to Get Rid of Double Backslash in Python Windows File Path String
Paramiko Ssh Die/Hang with Big Output
Timeout for Python Requests.Get Entire Response
Get Fully Qualified Class Name of an Object in Python
How to Calculate Mean Values Grouped on Another Column in Pandas
How to Convert a Time.Struct_Time Object into a Datetime Object
Python Script to Copy Text to Clipboard
How to Add a String in a Certain Position
Complexity of *In* Operator in Python
Filling in Login Forms in Instagram Using Selenium and Webdriver (Chrome) Python Osx
Validate Ssl Certificates with Python
Pandas/Python: Set Value of One Column Based on Value in Another Column