Search code examples
pythonipythonpywin32anaconda

Using pywin32 with iPython


I'm trying to use python with an excel document and trying to use pywin32 to access COM objects. My problem: I can't figure out install pywin32 so I can use it with iPython. Running the installer, it only detects my python27 installation and installs there.

When I run program with import win32com.client from cmd, it works fine. Trying to do the same in iPython and there is an ImportError. I'm pretty sure this is because their are two different system paths and win32com.client is only on one of them (sys.path in iPython only has things in C:\\Anaconda).

The iPython console is way easier to use than cmd for running and debugging programs, so I would really like to keep using it but I'm stuck.


Solution

  • You are correct that package installed to wrong python installation.

    Also if you install pywin32 make sure you use the correct python when you install windows (unlike mac) allows you to run setup.py directly. This will use the 1st python in your path to determine install location.

    Standard install:

    python setup.py install
    

    On windows the python is optional, but importantly still implied.

    type:

    where python
    

    at command prompt to see which python will be used to run setup.py

    You can also try:

    /full_path/python setup.py install