Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'pykeyboard' #6

Closed
nck974 opened this issue Apr 13, 2021 · 6 comments
Closed

ModuleNotFoundError: No module named 'pykeyboard' #6

nck974 opened this issue Apr 13, 2021 · 6 comments

Comments

@nck974
Copy link

nck974 commented Apr 13, 2021

So I was continueing from #5, and then when I executed poetry run aw-watcher-input and I get:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\Users\myuser\activity_monitor\aw-watcher-input\src\aw_watcher_input\__init__.py", line 1, in <module>
    from . import main
  File "C:\Users\myuser\activity_monitor\aw-watcher-input\src\aw_watcher_input\main.py", line 9, in <module>
    from aw_watcher_afk.listeners import KeyboardListener, MouseListener
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\aw_watcher_afk\listeners.py", line 6, in <module>
    from pykeyboard import PyKeyboardEvent
ModuleNotFoundError: No module named 'pykeyboard'

I tried installing `pip install pykeyboard`` but I think that has to be done somehow inside the virtual environment as It did not seem to work.

@ErikBjare
Copy link
Member

The module missing is pyuserinput (which contains pykeyboard), you can try installing it in the venv with poetry run pip install pyuserinput.

It's not being installed since aw-watcher-afk doesn't require it on Windows (it uses another approach for AFK detection), but aw-watcher-input needs it on all platforms to function, so it should probably be added to the dependencies. I'll look into it.

@nck974
Copy link
Author

nck974 commented Apr 13, 2021

Thanks, thant worked, but again I have a new one:

PS C:\Users\myuser\activity_monitor\aw-watcher-input> poetry run aw-watcher-input
INFO:aw_watcher_input.main:Starting watcher...
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\click\core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\click\core.py", line 782, in main
    rv = self.invoke(ctx)
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\click\core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\click\core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "C:\Users\myuser\activity_monitor\aw-watcher-input\src\aw_watcher_input\main.py", line 27, in main
    keyboard = KeyboardListener()
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\aw_watcher_afk\listeners.py", line 23, in __init__
    PyKeyboardEvent.__init__(self)
  File "C:\Users\myuser\AppData\Local\pypoetry\Cache\virtualenvs\aw-watcher-input-SuTwwcev-py3.9\lib\site-packages\pykeyboard\windows.py", line 232, in __init__
    import pyHook
ModuleNotFoundError: No module named 'pyHook'
PS C:\Users\myuser\activity_monitor\aw-watcher-input> poetry run pip install pyHook
ERROR: Could not find a version that satisfies the requirement pyHook
ERROR: No matching distribution found for pyHook

@ErikBjare
Copy link
Member

ErikBjare commented Apr 13, 2021

That's an issue with PyHook/PyWinHook which doesn't have any Python 3.9 compatible version on PyPI. See these lines in aw-watcher-afk: https://github.com/ActivityWatch/aw-watcher-afk/blob/9fc0e788e89e0982065d04e96dcf2abb5a44aa83/pyproject.toml#L18-L19

Try using Python 3.8 instead.

I also updated the pyproject.toml in 3f88423, so pyuserinput should now be installed correctly on poetry install.

@nck974
Copy link
Author

nck974 commented Apr 13, 2021

@ErikBjare thank your for your help, unfortunately I think I can not further test the project, as I am not really familiar with handling multiple versions of python as I just installed my python with chocolatey and I need python 3.9 for other project.

I really appreaciate your time anyway.

@ErikBjare
Copy link
Member

@nck974 That's okay. Thanks for being the first to test it out on Windows!

@ErikBjare
Copy link
Member

The switch to pynput was completed in a232b68.

Should work on Windows now, but let me know if it doesn't!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants