ModuleNotFoundError: No module named 'windows'

Viewed 11445

I'm working on a project and I need to use the PyMouse module.

pip install pymouse

installed pymouse correctly, so I assumed all was fine. However, when importing PyMouse:

from pymouse import PyMouse

I got the following error running my program:

Traceback (most recent call last):
  File "4opeenrij.py", line 1, in <module>
    from pymouse import PyMouseEvent
  File "C:\Users\lcdew\AppData\Local\Programs\Python\Python37-32\lib\site-packages\pymouse\__init__.py", line 92, in <module>
    from windows import PyMouse, PyMouseEvent
ModuleNotFoundError: No module named 'windows'

I can't seem to figure out what might cause this error message. Any help would be much appreciated.

Additional info:

I'm using Python 3.7 32 bit

Current pip version: 18.1

I have Windows 10

working on a 64-bit operating system

2 Answers

I had I look into this and became puzzled at first, so looked deeper. It turns out that pymouse is absolutely full of errors. More that I bothered to find. The error you got is just one of many errors caused by bad coding.

The code says:

from windows import PyMouse, PyMouseEvent

And it should say:

from .windows import PyMouse, PyMouseEvent

Also, PyUserInput, a sister package that is free from the pymouse errors, requires pyhook, which is unsupported by python 3. After a lot of looking around, the conclusion that there is no way around the problems found, except maybe installing a really early version.

You could also try the keyboard module.

You might want to take a look at pynput module. It works on python 3.8, doesn't have any incompatible dependencies, and doesn't seem to have any errors. Once you have the module installed, this page gives some good examples of various ways to manage the mouse.

Related