2017-07-27 76 views
0

這是我的代碼:使用pywin32模塊獲取此錯誤?

import win32com.client 

outlook = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") 

inbox = outlook.GetDefaultFolder(6) 
messages = inbox.Items 
message = messages.GetLast() 
body_content = message.body 
print (body_content) 

,我收到以下錯誤:

C:\Users\bre\AppData\Local\Programs\Python\Python36-32\python.exe C:/Users/bre/PycharmProjects/test/TkinterApp/test13.py 
Traceback (most recent call last): 
    File "C:/Users/bre/PycharmProjects/test/TkinterApp/test13.py", line 1, in <module> 
    import win32com.client 
    File "C:\Users\bre\AppData\Local\Programs\Python\Python36-32\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. 

Process finished with exit code 1 

究竟這是否意味着,我怎麼就能夠解決這個問題?我看到我可以下載一些DLL,但我沒有處理這方面的經驗。有關如何進行此項工作的任何建議或逐步建議?

回答

1

如果你看看你的Traceback錯誤,你可以看到你錯在哪裏。在你的test13.py文件的第1行和win32包的第5行中。首先要問的是「錯誤是什麼意思?」看看這裏:import win32api error in Python 2.6。雖然它是Python 2的參考,它應該給你一個在類似情況下做什麼的好主意。看起來你必須將一些dll文件從它們當前所在的位置移動到Python36-32目錄中的包目錄。爲了您可能的Python 3需求,這裏有一個很好的參考:https://github.com/pyinstaller/pyinstaller/issues/1840