I have tried everything given and the tutorials all point in the same direction about using mingw as a compiler in python instead of visual c++.
I do have visual c++ and mingw both. Problem started coming when I wanted to install using pip. It always gave Unable to find vcvarsall.bat
So as per suggestions I created a file distutils.cfg
under the following path c:/python27/Lib/distutils/
and added the following two lines:
[build]
compiler=mingw32
However, this file has no effect whatsoever. The same error still exists while using pip. I am trying to install numpy by the way currently although the error came earlier also.
Do you happen to use
virtualenv
as well?Anyway, use Microsoft Visual C++ Compiler for Python 2.7 and a newer
setuptools
. The one bundled with virtualenv (3.6) does not support this compiler.pip install "setuptools>=6.0"
Credits: http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/
Difficult Solution (Building using the C/C++ compiler)
Are you on Windows 32bit or 64bit? Are you specifying the build when you're compiling? For example, do the following in your shell or bash:
Easier Solution (Use pre-built binaries)
If you don't have to compile the program, you can use the unofficial Windows binaries from here
Cost me several hours to figure this out but now works like a charm. I am on Windows 64bit and using a scientific Python distribution Enthought Canopy.
Ensure you have installed MinGW and the Compilers you need (C, C++, Fortran..)
Add
C:\MingW\bin
to your PATH in Environment variablesIn
C:\Users\MyName\AppData\Local\Enthought\Canopy32\App\appdata\canopy-1.6.2.3262.win-x86\Lib\distutils
, create with notepad++ or similiar a new filedistutils.cfg
Write and save: