每当我尝试运行我的python代码时,就会发生导入错误,我对python相对较新,并且想知道什么是解决它的最有效方法,为什么它首先发生?
Traceback (most recent call last):
File "C:/Users/Admin/Documents/1 Tor/logger.py", line 2, in <module>
import pythoncom
File "C:\Python34\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
File "C:\Python34\lib\site-packages\win32\lib\pywintypes.py", line 124, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Python34\lib\site-packages\win32\lib\pywintypes.py", line 98, in __import_pywin32_system_module__
raise ImportError("No system module '%s' (%s)" % (modname, filename))
ImportError: No system module 'pywintypes' (pywintypes34.dll)
这是我的原始代码:
import pyHook
import pythoncom
import sys
import logging
file_log = 'C:\\Users\\Admin\\Documents\\1 Tor\\log.txt'
def OnKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='% (message)s')
chr(event.Ascii)
logging.log(10,chr(event.Ascii))
return True
hooks_manager = pyHook.HookManager()
hooks_manager.KeyDown = OnKeyboardEvent()
hooks_manager.HookKeyboard()
pythoncom.PumpMessages()
答案 0 :(得分:0)
pythoncom 需要一个名为 pywintypes 的软件包,该软件包尚未安装。您需要下载并安装它。由于您缺少一个包,您可能会遗漏其他包。查看 pythoncom 文档,看看是否有必须首先安装的依赖项列表。