Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Keyboard module not found

I am trying to use the keyboard module and import it by saying

import keyboard as kbd

For some reason, VSCode shows an error saying import keyboard could not be resolved and when running the program, I get an error message saying

Traceback (most recent call last):
  File "e:\Code\Python Code\Projects\cubingTimer.py", line 1, in <module>
    import keyboard as kbd
ModuleNotFoundError: No module named 'keyboard'

How do i fix this?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Did you install the module before importing it?
If not then install using
pip install keyboard

convert the module name to a shorter form by giving an alias name to it.
Modules can be imported under an alias name. using as keyword. See

import keyboard as kbd
kbd.write("Hello world\n")
import keyboard
keyboard.write("Hello world\n")
from keyboard import write
write("Hello world\n")

Whenever one variable’s value is assigned to another variable, because variables are just names that store references to values.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading