This question already has an answer here:
- import win32api error in Python 2.6 10 answers
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?
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.
After I copied
pywintypes26.dll
andpythoncom26.dll
toc:\Python26\Lib\site-packages\win32
I solved the problem!
quoted from here
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.
来源:https://stackoverflow.com/questions/22490233/win32com-import-error-python-3-4