Python distutils refuses to recognise installed C++ compilers, `Unable to find vcvarsall.bat` under Python 3.5 - c++

I'm tearing my hair out trying to compile c though Python's distutils. Specifically I'm trying to get started with Cython following this guide: http://docs.cython.org/src/quickstart/build.html, using a setup.py.
I'm running Python 3.5.0 under Anaconda 2.4.0 (64-bit), Windows 7.
I get the Unable to find vcvarsall.bat error referred to here: Cannot find vcvarsall.bat when running a Python script and in various other questions.
None of the proposed solutions work for me. So far I have tried:
installing Visual Studio - I have all versions from 2008 to 2013, ie 9.0, 10.0, 11.0, and 12.0.
pointing environment variables (VS100COMNTOOLS etc) related to the above directly to the correct locations
installing Microsoft Visual C++ Compiler for Python (as above link). This seemed to work but I get a compilation error that seems to be an incompatibility; I think because the compiler is intended for Python 2.7.
Ravi Kumar's suggestion at the above link to update pip's setuptools. Pip gave me an error saying it couldn't update.
Installing MS Windows SDK for Windows 7 and .NET Framework 4 as https://github.com/cython/cython/wiki/CythonExtensionsOnWindows. The final step failed with an error message that the x64 compilers aren't currently installed.
The only thing I can think of is installing MinGW which I've seen suggested in some places, but that CythonExtensionsOnWindows link specifically recommended against it.
Any other suggestions would be very welcome! In particular, since I clearly have all the versions of VS I could possibly need, is there a way to force Python to recognise them, other than setting environment variables VS100COMNTOOLS or similar?
Interestingly conda does seem to recognise the installed compilers, as a separate pip install attempt that failed with this same error, worked with conda.

As it turns out, Python 3.5 needs Visual Studio 2015. Advice elsewhere on fixing this for other Python versions is outdated.
Get Visual Studio 2015 Community here: https://www.visualstudio.com/en-us/downloads/visual-studio-2015-downloads-vs.aspx, this worked for me with no further steps needed.
Many thanks to Ionel, apparently the only place on the web to find this information! http://blog.ionelmc.ro/2014/12/21/compiling-python-extensions-on-windows/

Related

C++ OSX Setup w/ Vs Code or?

I have to use c++ 11 for class and I was wondering how I go about setting that up on a MAC? I need to be sure it is specifically c++ 11 or I will fail.
I liked the themes in VS Code and would like to do it with this program, but I am open to suggestions.
One answer would be to use Xcode, but personally I use Atom as my text editor and have several different compilers installed.
You will most likely need to install Xcode just for the build tools that come with it. You could install GCC or Clang via Homebrew or a package manager of your choice.(Yyou will need a working C++ compiler to install Gcc or clang via homebrew)
My suggested course of action would be to:
Install Xcode (From Mac App Store)
Install Homebrew(optional)
Install GCC and or Clang (optional)
Install a text editor like Atom or VSCode
The latest versions of GCC, Clang And Apples LLVM compiler will be able to compile C++11 and C++14.
If you choose to go with Atom, VSCode, etc... you will need to learn how to compile from the command line or use Make(Which is what I usually do)
It sounds to me like you go to a school that uses MS Visual Studio and you are seeking a replacement? If so you may run into trouble down the line not having Visual Studio. If your courses are going to be using Visual Studio I might suggest Dual Booting your Mac with Windows and Installing Visual Studio on there.(Though you will need copies of each, but your school may provide. Mine did) That is how I got through most of my programming classes that depended on Visual Studio.
EDIT:
Additionally you will need to make sure that you have make installed on your system. Try running make -v from your terminal. If you get command not found you will need to install it, it comes with Xcode or you can install it via Homebrew.

pyproj with Python 2.7.9 on win7 64 gives "Unable to find vcvarsall.bat"

I need to install pyproj on my machine and it give the above mentioned error. I guess it would be the same for other python components that are using C++ code:
My situation:
Win 7 64 bit running.
installed:
VS 2008 express
MS VS patch for python 2.7 http://www.microsoft.com/en-us/download/confirmation.aspx?id=44266
Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1 http://www.microsoft.com/downloads/en/details.aspx?FamilyID=c17ba869-9671-4330-a63e-1fd44e0e2505
Python Setup Tools available here: http://pypi.python.org/pypi/setuptools#downloads
set up the path variables and set
VS90COMNTOOLS
Value: C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools
I try to install the pyproj: http://jswhit.github.io/pyproj/
but it returns the same error:
File "msvc9compiler.py", line 271, in query_vcvarsall raise DistutilsPlatformError("Unable to find vcvarsall.bat") distutils.errors.DistutilsPlatformError: Unable to find vcvarsall.bat
the purpose of this is to get the pygrib package running: http://jswhit.github.io/pygrib/docs/index.html
Does anybody know how to solve the problem?
You can install this without needing to compile it by using a precompiled Python wheel. You can find a compatible wheel for pyproj at this page containing unofficial wheels.
You are specifically looking for pyproj-1.9.4-cp27-none-win_amd64.whl. Once you download the whl file, you can install it with pip using
pip install pyproj-1.9.4-cp27-none-win_amd64.whl
And that will install it for you, skipping the compilation process.

Having trouble getting Python to recognize location of vcvarsall.bat

I was trying to install RandomWords which requires ujson, at some point in the installation I received the following notification: "error: Unable to find vcvarsall.bat" I searched here, on stackoverflow, and came across some answers as the to root of this problem. In this answer https://stackoverflow.com/a/8705722, near the end, the OP pointed out that Microsoft had released a C++ compiler package for Python 2.7 (http://www.microsoft.com/en-us/download/details.aspx?id=44266).
I installed this package but still haven't had any success in installing ujson. So far I've tried the following:
Adding the location of vcvarsall.bat to the path environment variable
Manually tried loading the VC++ compiler's environment into the session by executing vcvars64.bat (aI've tried vcvars32.bat as well) as recommended here: https://stackoverflow.com/a/18045219
I've also tried installing the compilers found in "Windows SDK for Windows 7 and .NET Framework 3.5 SP1" found here: http://www.microsoft.com/en-us/download/details.aspx?id=3138
Not sure where to go from here, any suggestions/help would be greatly appreciated.
For reference here's some relevant specs:
Windows 8.1 (64-bit)
Python 2.7 (64-bit)
I've been trying to install said package using pip from the command prompt (e.g. '> pip install ujson')
I've uninstalled all the C++ compiler packages I've tried except this one: http://www.microsoft.com/en-us/download/details.aspx?id=44266
Really don't feel like installing mingw, but I'll try it if it seems like it's the only solution.
-UPDATE-
I ended up modifying "msvc9compiler.py" and manually setting the location of vcvarsall.bat by setting the value of the vcvarsall variable to the location of that batch file. Everything compiled fine but this is not a recommended solution. I'm pretty sure the compiler version I have matches the one python 2.7 uses, but as mentioned in an answer, in another question on this topic, if these don't match it can cause problems since "the compilers will probably have incompatible C runtime libraries."

Python 2.7 can't find vcvarsall.bat, MS VS C++ 2008 is installed

So I've been working with python 2.7 no problem for a while now. I've been using pip for a couple of months without issue. I recently installed virtualenv and now none of my pythons or pip can find vcvarsall.bat, even though this wasn't a problem before. I thought virtualenv seemed like a good idea, but not if it breaks everything around it. I tried to run repair on VS C++ but it didn't find any problems. Has anyone run into something like this before?
Seems that the problem is that Python 2.7 64 bit has a compilation problem. It would seem that I need to download a special package from MS to get access to 64-bit c/c++ compiler that's compatible with Python 2.7. Not a problem, except that's its 3 gigabytes. So, I just did it on my Linux VM and Windows Python 2.7 is 32-bit for me now. Not the best solution, but we're supposedly going to upgrade to Python 3 one of these years. Probably about when Python 4 comes out and the Python 3 compiler is obsolete too. C'est le vie!

Testing Scipy; get "No module named msvccompiler in numpy.distutils; trying from distutils"

I'm trying to test my scipy install by installing nose and entering
import scipy
scipy.test('1','10')
I get some 200 errors but one of the more common is:
.... No module named msvccompiler in numpy.distutils; trying from distutils
Missing compiler_cxx fix for MSVCCompiler
I have MS Virtual Studio 2009 installed (required for python 2.7)
Can anyone help me eliminate that error or tell my why I can't?
Thanks
You have to do 2 things to make it find the Visual Studio Compiler:
In your environment, set VS90COMNTOOLS=%VS__vvv__COMNTOOLS% where vvv is your installed version. See other related questions on stackoverflow about setup.py and vcvarsall.bat
Run python from a Visual Studio Developer Command Prompt. VS includes a link for this in the start menu. It sets up all the environment variables you need to run the compilers and related tools from the command line.
Best solution to this could be using the Anaconda Python distribution
It has most of the engineering and data analysis packages and automatically sets path of the C++ compiler. You can easily install numpy, scipy, matplotlib etc. using Anaconda. It will not show vcvarshall.bat as well as numpy.core.multiarray error for numpy