So I am having problems with importing the Keyboard module.
I tried installing it:
pip3 install keyboard
and pip install keyboard
It still gives me the same output:
ModuleNotFoundError: No module named 'keyboard'
I tried solving this using the solution at:
How to fix Error "No module named 'pynput'"? even after downloading with pip?
I know its a different module but I thought I can use the python -m pip install
command, but I still get the same result.
I tried checking all the module I installed using pip freeze
, the keyboard module was there but I can't import it.
If anyone ever encountered this and has resolved this issue, please let me know.
I am using Python version 3.9.6.

- 3
- 1
- 4
-
1Umm... What OS are you using like Mac, Windows... Cause it may also affect – Sep 01 '21 at 04:01
-
1I am using macOS Monterey 12.0 Beta – Hoàng Bùi Bảo Sep 01 '21 at 04:03
-
Hmm... I am also using a mac but not the Monterey 12.0 Beta version, did you activate the `anaconda` by typing `conda activate` – Sep 01 '21 at 04:05
-
1No I haven't, whats anaconda? I searched on google and it seems to be a database module. – Hoàng Bùi Bảo Sep 01 '21 at 04:07
2 Answers
Check your python location and see if it's the same one as the python location in your editor. You can check your python location by opening command prompt or any other terminal,
then type where python
if you are in window command prompt,
Get-Command python
in windows powershell or
type which python
if you are in mac, and now see in your editor if it's the same.

- 1,498
- 9
- 18
-
OMG, thank you so much. I didn't notice that VS Code defaulted to Python 2.7 for some reason. – Hoàng Bùi Bảo Sep 01 '21 at 04:09
I have noticed that you have not been using Anaconda, which is essential for installing in MacOS cause of some reasons. Please go to
https://www.anaconda.com/products/individual#Downloads
and install anaconda. Then follow the installation process and it should work. This is because MacOS has already python 2.7
per-installed, so you will have to install Anaconda to use python 3
and above. Using Anaconda, you can install any python packages without any error

- 30,962
- 25
- 85
- 135