This has been asked and answered a few times, but as you'll see none of the previous answers work for me -- I feel like something had changed to make all the old answers outdated. Or at the very least, I'm in some kind of edge case:
On a Windows 7 box, I've installed MinGW32 and Python 2.7 (32 bit version) (I've also tried this with Python 2.6 and got the same results).
Path environment variable is set correctly.
I've edited cygwincompiler.py
to remove refrences to -mno-cygwin
. And I've put the correct distutils.cfg
file into C:\Python27\Lib\distutils
.
To be clear: distutils.cfg
contains [build] compiler=mingw32
on two lines.
I've also (just to be safe) put pydistutils.cfg
in my %HOME%
directory. And put setup.cfg
in my current directory when running pip
. They have same content as distutils.cfg
.
I know this is all working because pip install cython
and pip install pycrypto
both compile successfully.
However, mysteriously, some packages still give me the unable to find vcvarsall.bat
error. Two examples are: pyproj and numpy.
It's as if sometimes pip
knows to use the MinGW compiler and sometimes it doesn't?
Moreover, if I use the MSYS shell that comes with MinGW then magically pip install numpy
succeeds. But pip install pyproj
still fails with an unable to find vcvarsall.bat
.
I've tried this out on several machines all with the exact same results.
Anybody have any idea what's going on here? Why would pip
know to use mingw32 to compile some c modules and not others? Also, why does pip install numpy
work inside the MSYS shell but not inside the cmd shell?
BONUS: Many, many older answers suggest installing Visual Studio 2008 as a way of solving a vcvarsall.bat
error. But as of this past May, microsoft is no longer distributing this software. Does anyone know of a place where one can still download VS2008? I ask because it's possible that being able to use vcvarsall.bat
instead of MinGW would solve this problem.
Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process.
MinGW is an alternative C/C++ compiler that works with all Python versions up to 3.4.
Install the downloaded package into a local directory : python get-pip.py --user This will install pip to your local directory (. local/bin) . Now you may navigate to this directory (cd . local/bin) and then use pip or better set your $PATH variable this directory to use pip anywhere : PATH=$PATH:~/.
visual studio express 2008 http://download.microsoft.com/download/8/B/5/8B5804AD-4990-40D0-A6AA-CE894CBBB3DC/VS2008ExpressENUX1397868.iso
Or if you're a student, you can still get Visual Studio 2008 through dreamspark https://www.dreamspark.com/
IMHO I'd recommend using Visual Studio 2008 because the official distributions of Python are all compiled with Visual Studio and is the "official" windows compiler for cpython. http://mail.python.org/pipermail/python-list/2010-April/573606.html
FYI Python 33 is compiled with Visual Studio 2010.
Finally, you could just install packages from here: http://www.lfd.uci.edu/~gohlke/pythonlibs/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With