There is Win 7 x64, Python 3.5.1 x64, Visual Studio C++ 2008 Express, vcvarsall.bat is located in the C: \ Program Files (x86) \ Microsoft Visual Studio 9.0 \ VC directory.
I registered this directory in PATH, created a productdir entry in the register, manually registered the path as .bat in msvc9compiler.py in the vcvarsall variable
Nothing helps, I still get an error, what can I do about it?
Answer 1, authority 100%
If you still want to compile with Visual Studio C++ instead of using mingw …
- Run python.exe to see which version of VC++ it was compiled with (example shown below).
It is important to use the appropriate version of the Visual C++ compiler, with
which Python was compiled since distilutils’s
get_build_version prevents mixing versions.
In your case Python 3.5.1 x64 and Visual Studio C++ 2008 don’t mix
Use the table below to map the internal VC++ version to the corresponding Visual Studio release:
MSC v. 1000 - & gt; Visual C++ 4.x
MSC v. 1100 - & gt; Visual C++ 5
MSC v. 1200 - & gt; Visual C++ 6
MSC v. 1300 - & gt; Visual C++ .NET
MSC v. 1310 - & gt; Visual C++ .NET 2003
MSC v. 1400 - & gt; Visual C++ 2005 (8.0)
MSC v. 1500 - & gt; Visual C++ 2008 (9.0)
MSC v. 1600 - & gt; Visual C++ 2010 (10.0)
MSC v. 1700 - & gt; Visual C++ 2012 (11.0)
MSC v. 1800 - & gt; Visual C++ 2013 (12.0)
MSC v. 1900 - & gt; Visual C++ 2015 (14.0)
MSC v. 1910 - & gt; Visual C++ 2017 (15.0)
MSC v. 1911 - & gt; Visual C++ 2017 (15.3)
MSC v. 1912 - & gt; Visual C++ 2017 (15.5)
MSC v. 1913 - & gt; Visual C++ 2017 (15.6)
MSC v. 1914 - & gt; Visual C++ 2017 (15.7)
MSC v. 1915 - & gt; Visual C++ 2017 (15.8)
MSC v. 1916 - & gt; Visual C++ 2017 (15.9)
- Download and install the appropriate version of Visual Studio C++ from the previous step.
Notes for Visual Studio C++ 2015
If you don’t need the Visual Studio IDE, download the Visual Studio C++ 2015 Build Tools.
Notes for Visual Studio C++ 2017
If you don’t need the Visual Studio IDE, download Build Tools for Visual Studio 2017.
Note: If you have a 32- and 64-bit Python installation, you can use virtualenv to create separate Python environments so you can use one or the other at the same time and don’t bother with your system path to choose which version of Python to use.
You can skip downloading the batch file manually (steps 4-6) by copying a few batch files to where Python is looking for, like this is the answer. If that doesn’t work, here are the following steps that initially worked for me.
Before you try to install something that requires C extensions, run the following batch file to load the VC++ compiler environment into the session (i.e. environment variables, compiler path, etc
Note: 32-bit Windows installations will be
C: \ Program Files \ as expected
"c: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ Tools \ vsvars32.bat"
"c: \ Program Files (x86) \ Microsoft Visual Studio 10.0 \ Common7 \ Tools \ vsvars64.bat"
Note: Yes, native 64-bit compilers are in Program Files (x86). Don’t ask me why.
Also, if you are wondering what is the difference between vcvars64.bat and vcvarsx86_amd64.bat, or more importantly, the difference between amd64 and x86_amd64, the former are for the built-in tools of 64-bit compilers, while the latter are 64- bit cross-compilers that can run on a 32-bit Windows installation.
If for any reason you get an error:
error: ... was unexpected at this time ...
... is a series of characters, then you need to make sure that there are no extraneous characters in the path variable, such as extra quotes or random characters. The batch file will not be able to update your session path if it cannot figure it out from the start.
If all went well, you should receive one of the following messages depending on which version of VC++ and which command you were running:
For 32-bit compiler tools:
Setting environment for using Microsoft Visual Studio 20xx x86 tools.
For 64-bit compiler:
Setting environment for using Microsoft Visual Studio 20xx x64 tools.
Now run the installation again via
python setup.py install or
pip install pkg-name
Hopefully and fingers crossed, the planets are positioned correctly today to interact with VC++.