Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install win32com module in a virtualenv?

I have installed both virtualenv and pywin32 on my Windows 7 64-bit laptop, and each of them seems to work, but not with each other.

More specifically, if a virtualenv is active, then running import win32com.client in a python interactive shell fails with No module named win32com.client. The same expression succeeds, however, if no virtualenv is active.

When I try to install pywin32 with pip (which is how I normally install modules when a virtualenv is active), I get the error:

  Could not find any downloads that satisfy the requirement pywin32
No distributions at all found for pywin32

...even though pywin32 is one of the modules listed in the output of

pip search pywin32

Therefore, to install pywin32 at all I had to install it using an *.exe installer downloaded from SourceForge.

Is there any way to install pywin32 within a virtualenv?

like image 552
kjo Avatar asked Feb 16 '13 18:02

kjo


People also ask

What is win32com in Python?

win32com.server packageSupport for COM servers written in Python. The modules in this package provide most of the underlying framework for magically turning Python classes into COM servers, exposing the correct public methods, registering your server in the registry, etc.

How do I download win32api from Python?

There is no version of specific version of win32api . You have to get the pywin32 module which currently cannot be installed via pip . It is only available from this link at the moment. The install does not take long and it pretty much all done for you.

What is the use of win32com client?

The win32com. client package contains a number of modules to provide access to automation objects. This package supports both late and early bindings, as we will discuss.


1 Answers

UPDATE 2016

There is now a version of pywin32 on PyPI that can be installed with pip. It is called pypiwin32, and it installs the package using the binary wheel format.

https://pypi.python.org/pypi/pypiwin32

pip install pypiwin32

That will work in a virtualenv, or with tox, etc.


Below this line is my previous old answer. That is now outdated information.

OLD ANSWER - OUTDATED. Modern versions of virtualenv default to --no-site-packages. That means that not having access to global site-packages is now the default behavior. Sadly, (as of July 2014) you can not pip install pywin32 in to your virtualenv. (here's the bug report) If you want to get pywin32 running inside a virtualenv, activate the virtualenv and use easy_install and the pywin32 installer exe file. For example easy_install "C:\Path\To\Downloads\pywin32-219.win32-py3.4.exe"

Related question

like image 68
Christian Long Avatar answered Sep 30 '22 14:09

Christian Long