12

I just installed python 3.4 64bit and tried to install win32com. I have downloaded pywin32-218.win-amd64-py3.4.exe and ran it without any problem. pip freeze reports pywin32==218. However, when I try to import win32com.client I get following error:

Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import win32com.client
  File "C:\program files\Python34\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.

sys and os import without issue. import win32api is the problem.

Using the same procedure it worked fine for python 2.7.6 and python 3.3.4.

How can I fix this?

Palak.Maheria
  • 1,497
  • 2
  • 15
  • 32
foosion
  • 7,619
  • 25
  • 65
  • 102
  • In case anyone else is having this problem, see http://stackoverflow.com/questions/7238403/import-win32api-error-in-python-2-6 (and change 26 to 34) – foosion Mar 18 '14 at 20:32

3 Answers3

30

This worked without needing to copy DLLs in python 3.3.

Why do these need to be copied as in 2.6? Surely this should be fixed by now!

After some additional research I found that all you need to do is run the post install script as administrator.

python C:\Python34\Scripts\pywin32_postinstall.py -install

It appears that the install script isn't doing this step correctly.

JxAxMxIxN
  • 1,711
  • 1
  • 17
  • 20
David Woakes
  • 539
  • 4
  • 10
  • 6
    I had to run `python C:\Python34\Scripts\pywin32_postinstall.py -install` – Felix Zumstein Jun 12 '14 at 11:50
  • 1
    I have this problem but I don't have that script. Where can I get it? – cdarke Jul 25 '14 at 11:28
  • It should be there after installing Python 3.4. Either install again (after removing python) or install on another machine and check for it there. – David Woakes Jul 29 '14 at 13:16
  • This solves my problem partially. If I run with python in my current directory: `python C:\mypath\myscript.py` the post install script appears to have done it's job and is working as intended. If on the other hand I run with my target script in my currently directory: `C:\mypath\python myscript.py` the post script did not work and I had to do as TankorSmash suggested in another answer and move the DLLs into the win32 site-packages directory. – OxCantEven Jun 11 '15 at 13:29
8

After I copied pywintypes26.dll and pythoncom26.dll to c:\Python26\Lib\site-packages\win32 I solved the problem!

quoted from here

Community
  • 1
  • 1
TankorSmash
  • 12,186
  • 6
  • 68
  • 106
1

I'm also running python 3.4 64 bit in Windows 7, and I had the same problem.

I solved it as suggested in this Stack Overflow answer. Basically, I added the path where pywintypes34.dll was located to my system path and it worked.

In my case it was C:\Python34\Lib\site-packages\pywin32_system32. There has to be 2 DLLs "pythoncom34.dll","pywintypes34.dll" in the path.

Community
  • 1
  • 1