Search code examples
python-2.7pywin32canopyptvs

pywin32 not working with PTVS


I have been playing around with PTVS 2.1 Beta 2 and Visual Studio Express 2013 with upgrade 3. I liked a lot of the features in PTVS so I was excited to give it a try. So far it is OK, but I have one major and confusing problem.

I am running Enthought Canopy Express 32 bit.

I rely on the pywin32 library a lot to connect to com objects. When I tried running some of my code that uses pywin32 through PTVS it fails. The line that fails in my code is:

from win32com.client import *

Here is the error:

   File "C:\Users\[username]\AppData\Local\Enthought\Canopy32\User\lib\site-packages\win32com\__init__.py", line 5, in <module>
    import win32api, sys, os
ImportError: DLL load failed: The specified module could not be found.

The weird thing is that if I just launch an interpreter window outside of visual studio (C:\Users[username]\AppData\Local\Enthought\Canopy32\User\python.exe) then the same code works just fine.

I started by comparing sys.path between the two approaches and they are the same.

It appears to me that the win32api.pyd file fails to load some dll that it depends on. I opened win32api.pyd in dependency walker and with the exception of a number of deeply nested late loading dependencies, MSVCR90.DLL was the only thing that could not be located.

I tried copying this from the matplotlib\backends folder to the same folder as win32api.pyd but it did not help. MSVCR90.DLL is NOT in windows\system or windows\sysWOW64.

I would love to use PTVS as my goto, but I'm stuck if I can't get this to work. Any help would be appreciated!


Solution

  • I fixed the problem. Another install of VS 2013 for web was interfering some how. I un-installed it and the problem went away.