How to install pywin32 module in windows 7

Python Programming

Question or problem about Python programming:

I am trying to install pywin32. I downloaded it from sourceforge.net. When I run

setup.py install

it shows “Unable to find vcvarsall.bat”. I Googled about it and found that I have to install MinGW and set path then run

python setup.py build --compiler=mingw32

but it’s showing

Can't find a version in Windows.h

Can anybody help? (I have a trial version of Visual Studio 2010 Ultimate installed and MinGW C and C++ compiler installed. Operating system: Windows 7.)

Can anybody tell me a source from where I can download Python binaries already compiled in MinGW, so I don’t have to do all this. Or if I can get a python which already have Windows modules.

How to solve the problem:

Solution 1:

are you just trying to install it, or are you looking to build from source?

If you just need to install, the easiest way is to use the MSI installers provided here:

http://sourceforge.net/projects/pywin32/files/pywin32/
(for updated versions)

make sure you get the correct version (matches Python version, 32bit/64bit, etc)

Solution 2:

You can install pywin32 wheel packages from PYPI with PIP by pointing to this package: https://pypi.python.org/pypi/pypiwin32 No need to worry about first downloading the package, just use pip:

pip install pypiwin32

Currently I think this is “the easiest” way to get in working ๐Ÿ™‚ Hope this helps.

Solution 3:

I disagree with the accepted answer being “the easiest”, particularly if you want to use virtualenv.

You can use the Unofficial Windows Binaries instead. Download the appropriate wheel from there, and install it with pip:

pip install pywin32-219-cp27-none-win32.whl

(Make sure you pick the one for the right version and bitness of Python).

You might be able to get the URL and install it via pip without downloading it first, but they’re made it a bit harder to just grab the URL. Probably better to download it and host it somewhere yourself.

Solution 4:

I had the exact same problem. The problem was that Anaconda had not registered Python in the windows registry.

1) pip install pywin
2) execute this script to register Python in the windows registry
3) download the appropriate package form Corey Goldberg‘s answer and python will be detected

Solution 5:

Quoting the README at https://github.com/mhammond/pywin32:


By far the easiest way to use pywin32 is to grab binaries from the most recent release

Just download the installer for your version of Python from https://github.com/mhammond/pywin32/releases and run it, and you’re done.

Hope this helps!