win32com import error python 3.4 [duplicate]

喜夏-厌秋 提交于 2019-11-27 17:58:50

问题


This question already has an answer here:

  • import win32api error in Python 2.6 11 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?


回答1:


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.




回答2:


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

quoted from here




回答3:


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!