I tried to install pyHook, but all I seem to get when I try to run my program in the python shell to test it is this.

ImportError: No module named pyHook

I keep trying, and I have PyWin32, so I tried to install it like that by typing into admin cmd:

start python.exe Scripts\pyHook_postinstall -install

Nope. It still isn't installed. How can I get the module to actually be usable?

Dani AI

Generated

A common gotcha with pyHook is version compatibility. pyHook targets Python 2.7 on Windows and does not support Python 3. If you are on Python 3, install the maintained fork pyWinhook instead and update your imports accordingly (use import pyWinhook rather than pyHook). See pyWinhook on PyPI. pyHook/pyWinhook also require pywin32, which must match your Python’s bitness (32/64-bit).

If "pip is not recognized", you likely have PATH issues or multiple Python installs. On Windows, use the Python launcher so you always invoke the correct pip for the interpreter you are using:

py -0p
py --version
py -m pip install --upgrade pip
py -m pip install pywin32

Then install the hook package that matches your Python version:

  • Python 3.x:
    py -m pip install pyWinhook
  • Python 2.7 (ensure the wheel you downloaded matches cp27 and your 32/64-bit Python):
    py -m pip install C:\path\to\pyHook‑<version>‑cp27‑...whl

Verify you are importing into the same interpreter you installed to:

py -c "import sys,platform; print(sys.version); import win32api; import pyWinhook as _; print('OK')"

Tips:

Recommended Answers

All 5 Replies

In windows OS, the best solution is often to install a module from Christoph Gohlke's python binaries for windows. PyHook is <Here>.

Edit: Download the wheel file (.whl), then type pip install <filename.whl>

I have downloaded the .whl file, so I'll try that. Thanks!
Results: I tried to do that with my cmd, and got this:

'pip' is not recognized as an internal or external command, operable program or batch file.

By the way, if it changes anything, I am running Windows 8 on my computer.

Install pip first, by following the instructions given <here>.

Thank you!!!

Hey, by the way, my pywin32 actually did not install by the cmd that I put in, but I used pip to get it, so it's installed now.

T
H
A
N
K

Y
O
U
!
!
!
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.