Reputation: 8789
I tried to install the Python package dulwich:
pip install dulwich
But I get a cryptic error message:
error: Unable to find vcvarsall.bat
The same happens if I try installing the package manually:
> python setup.py install
running build_ext
building 'dulwich._objects' extension
error: Unable to find vcvarsall.bat
Upvotes: 878
Views: 964585
Reputation: 2362
basetsd.h is w file that belongs to Windows SDK. So you must have windows SDK installed. (Some may think that it is installed with VS, this is not correct)
Download from :
https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/
Upvotes: 0
Reputation: 49062
Use this link to download and install Visual C++ 2015 Build Tools. It will automatically download visualcppbuildtools_full.exe
and install Visual C++ 14.0 without actually installing Visual Studio. After the installation completes, retry pip install and you won't get the error again.
I have tested it on following platform and versions:
Python 3.6 on Windows 7 64-bit
Python 3.7 on Windows Server 2016 (64-bit system)
Python 3.8 on Windows 10 64-bit
Upvotes: 7
Reputation: 3217
calling import setuptools
will monkey patch distutils to force compatibility with Visual Studio. Calling vcvars32.bat
manually will setup the virtual environment and prevent other common errors the compiler will throw. For VS 2017 the file is located at
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
Here is the setup script I use to quickly compile .pyx files to .pyd: (Note: it uses the 3rd party module send2trash
# cython_setup.py
import sys, os, time, platform, subprocess
from setuptools import setup, find_packages
from Cython.Build import cythonize
from traceback import format_exc
# USAGE:
#
# from cython_setup import run
# run(pyx_path)
# vcvars = r"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat"
# NOTE: to use visual studio 2017 you must have setuptools version 34+
vcvars = r"C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars32.bat"
def _build_ext():
try:
pyx_path = sys.argv.pop(-1)
pyx_path = os.path.abspath(pyx_path)
if not os.path.exists(pyx_path):
raise FileNotFoundError(f"{pyx_path} does not exist")
project_name = sys.argv.pop(-1)
os.chdir(os.path.abspath(os.path.dirname(pyx_path)))
print("cwd: %s" % os.getcwd())
print(os.path.abspath("build"))
setup(
name=project_name,
# cmdclass = {'build_ext': build_ext},
packages=find_packages(),
# ext_modules=cythonize(extensions)
ext_modules=cythonize(pyx_path,
compiler_directives={'language_level': 3, 'infer_types': True, 'binding': False},
annotate=True),
# include_dirs = [numpy.get_include()]
build_dir=os.path.abspath("build")
)
except:
input(format_exc())
def retry(func):
def wrapper(*args, **kw):
tries = 0
while True:
try:
return func(*args, **kw)
except Exception:
tries += 1
if tries > 4:
raise
time.sleep(0.4)
return wrapper
@retry
def cleanup(pyx_path):
from send2trash import send2trash
c_file = os.path.splitext(pyx_path)[0] + ".c"
if os.path.exists(c_file):
os.remove(c_file)
if os.path.exists("build"):
send2trash("build")
def move_pyd_files(pyx_path):
pyx_dir = os.path.dirname(pyx_path)
build_dir = os.path.join(pyx_dir, "build")
if not os.path.exists(build_dir):
raise RuntimeError(f"build_dir {build_dir} did not exist....")
found_pyd = False
for top, dirs, nondirs in os.walk(build_dir):
for name in nondirs:
if name.lower().endswith(".pyd") or name.lower().endswith(".so"):
found_pyd = True
old_path = os.path.join(top, name)
new_path = os.path.join(pyx_dir, name)
if os.path.exists(new_path):
print(f"removing {new_path}")
os.remove(new_path)
print(f"file created at {new_path}")
os.rename(old_path, new_path)
if not found_pyd:
raise RuntimeError("Never found .pyd file to move")
def run(pyx_path):
"""
:param pyx_path:
:type pyx_path:
:return: this function creates the batch file, which in turn calls this module, which calls cythonize, once done
the batch script deletes itself... I'm sure theres a less convoluted way of doing this, but it works
:rtype:
"""
try:
project_name = os.path.splitext(os.path.basename(pyx_path))[0]
run_script(project_name, os.path.abspath(pyx_path))
except:
input(format_exc())
def run_script(project_name, pyx_path):
dirname = os.path.dirname(pyx_path)
# ------------------------------
os.chdir(dirname)
if os.path.exists(vcvars):
# raise RuntimeError(
# f"Could not find vcvars32.bat at {vcvars}\nis Visual Studio Installed?\nIs setuptools version > 34?")
subprocess.check_call(f'call "{vcvars}"', shell=True)
cmd = "python" if platform.system() == "Windows" else "python3"
subprocess.check_call(f'{cmd} "{__file__}" build_ext "{project_name}" "{pyx_path}"', shell=True)
move_pyd_files(pyx_path)
cleanup(pyx_path)
if len(sys.argv) > 2:
_build_ext()
Upvotes: 4
Reputation: 5980
Run python.exe
to display which version of VC++ it was compiled with (example shown below).
It is important to use the corresponding version of the Visual C++ compiler that Python was compiled with since distilutils's
get_build_version
prevents mixing versions (per Piotr's warning).
Use the table below[1] to match the internal VC++ version with the corresponding Visual Studio release:
MSC v.1000 -> Visual C++ 4.x
MSC v.1100 -> Visual C++ 5
MSC v.1200 -> Visual C++ 6
MSC v.1300 -> Visual C++ .NET
MSC v.1310 -> Visual C++ .NET 2003
MSC v.1400 -> Visual C++ 2005 (8.0)
MSC v.1500 -> Visual C++ 2008 (9.0)
MSC v.1600 -> Visual C++ 2010 (10.0)
MSC v.1700 -> Visual C++ 2012 (11.0)
MSC v.1800 -> Visual C++ 2013 (12.0)
MSC v.1900 -> Visual C++ 2015 (14.0)
MSC v.1910 -> Visual C++ 2017 (15.0)
MSC v.1911 -> Visual C++ 2017 (15.3)
MSC v.1912 -> Visual C++ 2017 (15.5)
MSC v.1913 -> Visual C++ 2017 (15.6)
MSC v.1914 -> Visual C++ 2017 (15.7)
MSC v.1915 -> Visual C++ 2017 (15.8)
MSC v.1916 -> Visual C++ 2017 (15.9)
Download and install the corresponding version of Visual Studio C++ from the previous step.
Additional notes for specific versions of VC++ are listed below.
For only the 32-bit compilers, download Visual Studio C++ 2008 Express Edition.
For the 64-bit compilers[2][3], download Windows SDK for Windows 7 and .NET Framework 3.5 SP1.
- Uncheck everything except
Developer Tools >> Visual C++ Compilers
to save time and disk space from installing SDK tools you otherwise don't need.
According to Microsoft, if you installed Visual Studio 2010 SP1, it may have removed the compilers and libraries for VC++.
If that is the case, download Visual C++ 2010 SP1 Compiler Update.
If you don't need the Visual Studio IDE, download Visual Studio C++ 2015 Build Tools.
If you don't need the Visual Studio IDE, download Build Tools for Visual Studio 2017.
Suggestion: If you have both a 32- and 64-bit Python installation, you may also want to use virtualenv to create separate Python environments so you can use one or the other at a time without messing with your path to choose which Python version to use.
According to @srodriguex, you may be able to skip manually loading the batch file (Steps 4-6) by instead copying a few batch files to where Python is searching by following this answer. If that doesn't work, here are the following steps that originally worked for me.
Open up a cmd.exe
Before you try installing something which requires C extensions, run the following batch file to load the VC++ compiler's environment into the session (i.e. environment variables, the path to the compiler, etc).
Execute:
32-bit Compilers:
Note: 32-bit Windows installs will only have C:\Program Files\
as expected
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars32.bat"
64-bit Compilers:
"C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\Tools\vsvars64.bat"
Note: Yes, the native 64-bit compilers are in Program Files (x86)
. Don't ask me why.
Additionally, if you are wondering what the difference between vcvars64.bat
and vcvarsx86_amd64.bat
or more importantly the difference between amd64
and x86_amd64
, the former are for the native 64-bit compiler tools and the latter are the 64-bit cross compilers that can run on a 32-bit Windows installation.
Update:
If for some reason you are getting error: ... was unexpected at this time.
where the ...
is some series of characters, then you need to check that you path variable does not have any extraneous characters like extra quotations or stray characters. The batch file is not going to be able to update your session path if it can't make sense of it in the first place.
If that went well, you should get one of the following messages depending on which version of VC++ and which command you ran:
For the 32-bit compiler tools:
Setting environment for using Microsoft Visual Studio 20xx x86 tools.
For the 64-bit compiler tools:
Setting environment for using Microsoft Visual Studio 20xx x64 tools.
Now, run the setup via python setup.py install
or pip install pkg-name
Hope and cross your fingers that the planets are aligned correctly for VC++ to cooperate.
Upvotes: 170
Reputation: 1705
The best and exhaustive answer to this issue is given here: https://blogs.msdn.microsoft.com/pythonengineering/2016/04/11/unable-to-find-vcvarsall-bat/
For most of cases it's enough to find the suitable .whl package for your required python dependency and install it with pip.
In the last case you'll have to install microsoft compiler and install your package from source code.
Upvotes: -2
Reputation: 2303
I didn't see any answer using vswhere which I think is the correct way to do it since Visual Studio 15.2.
Here's how I run vsvars64.bat (I guess it's similar for vsvarsall)
def init_vsvars():
cprint("")
cprint_header("Initializing vs vars")
vswhere_path = r"%ProgramFiles(x86)%/Microsoft Visual Studio/Installer/vswhere.exe"
vswhere_path = path.expandvars(vswhere_path)
if not path.exists(vswhere_path):
raise EnvironmentError("vswhere.exe not found at: %s", vswhere_path)
vs_path = common.run_process(".", vswhere_path,
["-latest", "-property", "installationPath"])
vs_path = vs_path.rstrip()
vsvars_path = os.path.join(vs_path, "VC/Auxiliary/Build/vcvars64.bat")
# common.run_process(".", vsvars_path, [])
os.system('"%s"' % vsvars_path)
run_process does a bunch of things but basically boils down to this:
output = ""
process = subprocess.Popen(
commandline,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
universal_newlines=True)
for stdout_line in iter(process.stdout.readline, ""):
cprint(stdout_line)
output += stdout_line
process.stdout.close()
return_code = process.wait()
return output
Upvotes: -1
Reputation: 121
Below steps fixed this issue for me, I was trying to create setup with cython extension.
For some reason distutils expects the vcvarsall.bat file to be within VC dir, but VC++ for python tools has it in the root of 9.0 To fix this, remove "VC" from the path.join (roughly around line 247)
#productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
productdir = os.path.join(toolsdir, os.pardir, os.pardir)
The above steps fixed the issue for me.
Upvotes: 4
Reputation: 27
I find a much easier way to do this. Just download binaries packages from website:http://www.lfd.uci.edu/~gohlke/pythonlibs' For example: autopy3‑0.51.1‑cp36‑cp36m‑win32.whl(cp36 means Python 3.6) Download it And install by pip install location of file
Upvotes: -1
Reputation: 8714
Update: Comments point out that the instructions here may be dangerous. Consider using the Visual C++ 2008 Express edition or the purpose-built Microsoft Visual C++ Compiler for Python (details) and NOT using the original answer below. Original error message means the required version of Visual C++ is not installed.
For Windows installations:
While running setup.py for package installations, Python 2.7 searches for an installed Visual Studio 2008. You can trick Python to use a newer Visual Studio by setting the correct path in VS90COMNTOOLS
environment variable before calling setup.py
.
Execute the following command based on the version of Visual Studio installed:
SET VS90COMNTOOLS=%VS100COMNTOOLS%
SET VS90COMNTOOLS=%VS110COMNTOOLS%
SET VS90COMNTOOLS=%VS120COMNTOOLS%
SET VS90COMNTOOLS=%VS140COMNTOOLS%
WARNING: As noted below, this answer is unlikely to work if you are trying to compile python modules.
See Building lxml for Python 2.7 on Windows for details.
Upvotes: 684
Reputation: 752
http://www.stickpeople.com/projects/python/win-psycopg/
Installing Appropriate file from above link fixed my issue.
Mention: Jason Erickson [[email protected]]. He manages this page fairly well for Windows users.
Upvotes: 0
Reputation: 53
I got the same problem and have solved it at the moment.
"Google" told me that I need to install "Microsoft Visual C++ Compiler for Python 2.7". I install not only the tool, but also Visual C++ 2008 Reditributable, but it didn't help. I then tried to install Visual C++ 2008 Express Edition. And the problem has gone!
Just try to install Visual C++ 2008 Express Edition!
Upvotes: 2
Reputation: 799
I am tried all the above answers, but not worked for me.
I was using Windows 10 and had installed Visual Studio 2010
In my case need add vcvars64.bat
to C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
below is vcvars64.bat:
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
Install Microsoft SDK 7.1 if you not install, and rerun pip install dulwich
Upvotes: 1
Reputation: 35986
An exhaustive list of MS VС++ versions and installation variations officially supported by distutils
(and some by setuptools
) and how to use them can be found at
https://wiki.python.org/moin/WindowsCompilers
It also specifies which VC++ version is required for which official Win32 Python release. Note that MinGW is not officially supported (see below for details).
In brief:
setuptools
and not distutils
.Upvotes: 2
Reputation: 65426
The easiest way to solve this in 2016 is to install Chocolatey and then the vcpython27
package. Open Powershell:
> iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
> choco install python2 -y
> choco install vcpython27 -y
Upvotes: 3
Reputation: 169
I encountered this issue when I tried to install numpy library on my python 3.5. The solution is to install VS2015. I had VS2008, 2012, 2013, none of which is compatible with python 3.5. Apparently newer version of python has dependency on newer versions of VS.
Also make sure C++ Common Tools are installed with Visual Studio.
Upvotes: 7
Reputation: 14432
I had the same error when I tried to install pandas in windows 10. After searching several solutions, I ended up with the use of wheel.
First of all, upgrade pip to the newest version:
easy_install install -U pip
Second, install wheel:
pip install wheel
Third, download the whl file for your package and install it:
pip install [xxx].whl
So far, I believe wheel is the best way to install Python packages on windows.
Upvotes: 0
Reputation: 605
I wanted to run pysph on Windows 10 under Python 2.7 and got vcvarsall.bat was not found (from distutils)
My solution was the following:
Install Microsoft Visual C++ for Python 2.7 (like @Michael suggested)
On Windows 10 it was installed into (my username is Andreas):
C:\Users\Andreas\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0
Set environment variable VS90COMNTOOLS to the installation path of Visual C++ for Python 2.7 (see above path).
If it still doesn't work, then modifiy in the module
C:/Python27/lib/distutils
the file msvc9compiler.py. Find in it the function find_vcvarsall and do following modification.
Replace the line:
productdir = os.path.join(toolsdir, os.pardir, os.pardir, "VC")
with
productdir = os.path.join(toolsdir)
This is where vcvarsall.bat resides in my case (check, where vcvarsall.bat is in your installation).
Upvotes: 7
Reputation: 1767
Is Microsoft Visual C++ Compiler for Python 2.7 at http://www.microsoft.com/en-us/download/details.aspx?id=44266 not a solution?
Upvotes: 3
Reputation: 2461
I don't know if it is too late, but I found Microsoft Visual C++ Compiler for Python 2.7 which reads
The typical error message you will receive if you need this compiler package is Unable to find vcvarsall.bat
Hope this helps!
Upvotes: 2
Reputation: 5279
I spent almost 2 days figuring out how to fix this problem in my python 3.4 64 bit version: Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 bit (AMD64)] on win32
Solution 1, hard: (before reading this, read first Solution 2 below) Finally, this is what helped me:
vcvars64.bat
in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64
which contains CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
or other path depending on where you have yours installedafter that I tried to pip install numpy
but received the following error:
File "numpy\core\setup.py", line 686, in get_mathlib_info
raise RuntimeError("Broken toolchain: cannot link a simple C program")
RuntimeError: Broken toolchain: cannot link a simple C program
I changed mfinfo
to None
in C:\Python34\Lib\distutils\msvc9compiler.py
per this https://stackoverflow.com/a/23099820/4383472
pip install numpy
command my avast antivirus tried to interfere into the installation process, but i quickly disabled itIt took very long - several minutes for numpy to compile, I even thought that there was an error, but finally everything was ok.
Solution 2, easy:
(I know this approach has already been mentioned in a highly voted answer, but let me repeat since it really is easier)
After going through all of this work I understood that the best way for me is just to use already precompiled binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/ in future. There is very small chance that I will ever need some package (or a version of a package) which this site doesn't contain. The installation process is also much quicker this way. For example, to install numpy
:
numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
(if you have Python 3.4 64-bit) from that sitepip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
(or full path to the file depending how command prompt is opened)Upvotes: 8
Reputation: 1347
Install Visual Studio 2015 Community Edition from https://www.visualstudio.com, then
for Python 3.4
set VS100COMNTOOLS=%VS140COMNTOOLS% && pip install XX
Upvotes: 1
Reputation: 5144
If you have mingw installed
pip install --global-option build_ext --global-option --compiler=mingw32 packagename
works, forcing pip to build using the mingw compiler instead of Microsoft's. See here https://github.com/pypa/pip/issues/18 for details (last post).
Upvotes: 3
Reputation: 70
Go here: http://docs.continuum.io/anaconda/install.html#windows-install
There are instructions to install anaconda which will provide a GUI and a silent install of a majority of the packages that seem to be causing this issue from http://www.scipy.org/. I am aware of the solution for 2.7 here https://www.microsoft.com/en-us/download/details.aspx?id=44266 but I did not see an option for Python 3.4. After downloading and installing Anaconda you should be able to import a majority of the packages you need from scipy.
Hope this helps some people. Took me 45 minutes of scouring posts and sites.
EDIT: Just wanted to note there is a Python34 link on the GUI page next to the OS symbols.
Upvotes: 1
Reputation: 10305
fastest solution:
If you have python 3.4.x, the solution is simply to install VC++ 2010 since it is used to compile itself into.
https://www.visualstudio.com/en-us/downloads#d-2010-express
my python version is MSC v.1600 32 bit (intel)] on win32
worked fine on Windows8
Upvotes: 1
Reputation: 461
I followed the instructions http://springflex.blogspot.ru/2014/02/how-to-fix-valueerror-when-trying-to.html. but nothing happened. Then I installed 2010 Visual Studio Express (http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express) following the advice http://blog.python.org/2012/05/recent-windows-changes-in-python-33.html it helped me
Upvotes: 0
Reputation: 11514
Look in the setup.py
file of the package you are trying to install. If it is an older package it may be importing distutils.core.setup()
rather than setuptools.setup()
.
I ran in to this (in 2015) with a combination of these factors:
The Microsoft Visual C++ Compiler for Python 2.7 from http://aka.ms/vcpython27
An older package that uses distutils.core.setup()
Trying to do python setup.py build
rather than using pip
.
If you use a recent version of pip, it will force (monkeypatch) the package to use setuptools, even if its setup.py
calls for distutils. However, if you are not using pip, and instead are just doing python setup.py build
, the build process will use distutils.core.setup()
, which does not know about the compiler install location.
Step 1: Open the appropriate Visual C++ 2008 Command Prompt
Open the Start menu or Start screen, and search for "Visual C++ 2008 32-bit Command Prompt" (if your python is 32-bit) or "Visual C++ 2008 64-bit Command Prompt" (if your python is 64-bit). Run it. The command prompt should say Visual C++ 2008 ... in the title bar.
Step 2: Set environment variables
Set these environment variables in the command prompt you just opened.
SET DISTUTILS_USE_SDK=1
SET MSSdk=1
Reference http://bugs.python.org/issue23246
Step 3: Build and install
cd
to the package you want to build, and run python setup.py build
, then python setup.py install
. If you want to install in to a virtualenv, activate it before you build.
Upvotes: 16
Reputation: 137514
What's going on? Python modules can be part written in C or C++ (typically for speed). If you try to install such a package with Pip (or setup.py
), it has to compile that C/C++ from source. Out the box, Pip will brazenly assume you the compiler Microsoft Visual C++ installed. If you don't have it, you'll see this cryptic error message "Error: Unable to find vcvarsall.bat".
The prescribed solution is to install a C/C++ compiler, either Microsoft Visual C++, or MinGW (an open-source project). However, installing and configuring either is prohibitively difficult. (Edit 2014: Microsoft have published a special C++ compiler for Python 2.7)
The easiest solution is to use Christoph Gohlke's Windows installers (.msi) for popular Python packages. He builds installers for Python 2.x and 3.x, 32 bit and 64 bit. You can download them from http://www.lfd.uci.edu/~gohlke/pythonlibs/
If you too think "Error: Unable to find vcvarsall.bat" is a ludicrously cryptic and unhelpful message, then please comment on the bug at http://bugs.python.org/issue2943 to replace it with a more helpful and user-friendly message.
For comparison, Ruby ships with a package manager Gem and offers a quasi-official C/C++ compiler, DevKit. If you try to install a package without it, you see this helpful friendly useful message:
Please update your PATH to include build tools or download the DevKit from http://rubyinstaller.org/downloads and follow the instructions at http://github.com/oneclick/rubyinstaller/wiki/Development-Kit
You can read a longer rant about Python packaging at https://stackoverflow.com/a/13445719/284795
Upvotes: 73
Reputation: 420
I had the same error (which I find silly and not really helpful whatsoever as error messages go) and continued having problems, despite having a C compiler available.
Surprising, what ended up working for me was simply upgrading pip and setuptools to the most recent version. Hope this helps someone else out there.
Upvotes: 1
Reputation: 1121138
You'll need to install a Microsoft compiler, compatible with the compiler used to build Python. This means you need Visual C++ 2008 (or newer, with some tweaking).
Microsoft now supplies a bundled compiler and headers just to be able to compile Python extensions, at the memorable URL:
Microsoft Visual C++ Compiler for Python 2.7
This is a relatively small package; 85MB to download, installable without admin privileges, no reboot required. The name is a little misleading, the compiler will work for any Python version originally compiled with Visual C++ 2008, not just Python 2.7.
If you start a Python interactive prompt or print sys.version
, look for the MSC
version string; if it is MSC v.1500
you can use this tool.
From the original announcement to the distutils list:
Microsoft has released a compiler package for Python 2.7 to make it easier for people to build and distribute their C extension modules on Windows. The Microsoft Visual C++ Compiler for Python 2.7 (a.k.a. VC9) is available from: http://aka.ms/vcpython27
This package contains all the tools and headers required to build C extension modules for Python 2.7 32-bit and 64-bit (note that some extension modules require 3rd party dependencies such as OpenSSL or libxml2 that are not included). Other versions of Python built with Visual C++ 2008 are also supported, so "Python 2.7" is just advertising - it'll work fine with 2.6 and 3.2.
Note that you need to have setuptools
6.0 or newer installed (listed in the system requirements on the download page). The project you are installing must use setuptools.setup()
, not distutils
or the auto-detection won't work.
Microsoft has stated that they want to keep the URL stable, so that automated scripts can reference it easily.
Upvotes: 64
Reputation: 1005
I had this problem using Python 3.4.1 on Windows 7 x64, and unfortunately the packages I needed didn't have suitable exe or wheels that I could use. This system requires a few 'workarounds', which are detailed below (and TLDR at bottom).
Using the info in Jaxrtech's answer above, I determined I needed Visual Studio C++ 2010 (sys.version return MSC v.1600), so I installed Visual C++ 2010 Express from the link in his answer, which is http://go.microsoft.com/?linkid=9709949. I installed everything with updates, but as you can read below, this was a mistake. Only the original version of Express should be installed at this time (no updated anything).
vcvarsall.bat was now present, but there was a new error when installing the package, query_vcvarsall raise ValueError(str(list(result.keys())))ValueError: [u'path']
. There are other stackoverflow questions with this error, such as Errors while building/installing C module for Python 2.7
I determined from that answer that 2010 Express only installs 32-bit compilers. To get 64-bit (and other) compilers, you need to install Windows 7.1 SDK. See http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx
This would not install for me though, and the installer returned the error installation failed with return code 5100
. I found the solution at the following link: http://support.microsoft.com/kb/2717426. In short, if newer versions of x86 and x64 Microsoft Visual C++ 2010 Redistributable's are installed, they conflict with the ones in SDK installer, and need uninstalling first.
The SDK then installed, but I noticed vcvars64.bat still did not exist in C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin
, nor its subfolders. vcvarsall.bat runs the vcvars64 batch file, so without it, the python package still wouldn't install (I forgot the error that was shown at this time).
I then found some instructions here: http://www.cryptohaze.com/wiki/index.php/Windows_7_Build_Setup#Download_VS_2010_and_Windows_SDK_7.1
Following the instructions, I had already installed Express and 7.1 SDK, so installed SDK 7.1 SP1, and did the missing header file fix. I then manually created vcvars64.bat with the content CALL setenv /x64
. I will paste all those instructions here, so they don't get lost.
Step 1 is to download Visual Studio Express 2010.
http://www.microsoft.com/visualstudio/en-us/products/2010-editions/express is a good place to start. Download the installer, and run it (vc_web.exe). You don't need the SQL 2008 additional download.
You'll also need the Windows SDK (currently 7.1) for the 64-bit compilers - unless you want to do 32-bit only builds, which are not fully supported...
http://www.microsoft.com/en-us/download/details.aspx?id=8279 is a good starting point to download this - you'll want to run winsdk_web.exe when downloaded!
The default install here is just fine.
Finally, download and install the Windows SDK 7.1 SP1 update: http://www.microsoft.com/en-us/download/details.aspx?id=4422
And, to fix missing header file, VS2010 SP1. http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=75568aa6-8107-475d-948a-ef22627e57a5
And, bloody hell, fix the missing batch file for VS2010 Express. This is getting downright absurd.
In C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64, create "vcvars64.bat" with the following (you will need to be running as administrator):
CALL setenv /x64
My python package still did not install (can't recall error). I then found some instructions (copied below) to use the special SDK 7.1 Command Prompt, see: https://mail.python.org/pipermail/distutils-sig/2012-February/018300.html
Never mind this question. Somebody here noticed this item on the menu: Start->All Programs->Microsoft Windows SDK v7.1 ->Windows SDK 7.1 Command Prompt
This runs a batch job that appears to set up a working environment for the compiler. From that prompt, you can type "setup.py build" or "setup.py install".
I opened the Windows SDK 7.1 Command Prompt as instructed, and used it to run easy_install on the python package. And at last, success!
TLDR;
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64\vcvars64.bat
with content CALL setenv /x64
Upvotes: 6