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?
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
I'm using Python 3.7.3 on Raspberry Pi, now the import keyboard is not longer required, just comment it or remove the line; all must works fine.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.