Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python module "keyboard" works on Windows, not found on Raspberry

I want to use module keyboard in Python 3.5.3.

pip, import and my program work fine on Windows. On my Raspberry pip install works and pip list shows keyboard.

However when I try to run import keyboard I get the error: "ImportError: No module named 'keyboard'"

I even tried to use sudo import as the keyboard documentation suggests with the same result.

What am I missing?

like image 761
Scott Free VT Avatar asked Mar 08 '23 02:03

Scott Free VT


1 Answers

You need to check which interpreter your pip is installing packages to.

You have both Python2 and Python3 installed on your PI, so only one of these will have access to the packages you are installing with pip.

You can check which interpreter your pip is installing packages to by running the following commands:

[root@pi] python2 -m pip list
[root@pi] python3 -m pip list

If pip is installing the packages to your Python2 installation, you will need to explicitly call the Python3 interpreter when installing the packages

[root@pi] python3 -m pip install keyboard
like image 96
AK47 Avatar answered Apr 25 '23 18:04

AK47