Search code examples
pythonimportpackageraspbian

pykeyboard not importing from its module


I am having an issue where the package PyKeyboard is unable to be imported from its library pykeyboard. When executing the following: from pykeyboard import PyKeyboard I am subjected to the following error:

  File "relay.py", line 9, in <module>
    from pykeyboard import PyKeyboard
ImportError: cannot import name 'PyKeyboard' from 'pykeyboard' (/home/pi/.local/lib/python3.7/site-packages/pykeyboard/__init__.py)

Uninstalling the package, running from root, or reinstalling Python lead me to no avail at all. I am at a brick wall.


Solution

  • Make sure the dependencies are installed. Considering that you are using PyUserInput 0.1.11 (as you said)

    Depending on your platform, you will need the following python modules for PyUserInput to function:

    • Linux - Xlib
    • Mac - Quartz, AppKit
    • Windows - pywin32, pyHook

    If you are using Windows, for installing pywin32 run

    pip install pywin32
    

    And for pyHook make sure to install your system's version. Here you'll find both 64 and 32. Note that for whl files one may need to install wheel, as

    pip install wheel
    

    And then

    wheel install file_name.whl
    

    When the dependencies are installed, install the package with

    pip install PyUserInput