Keyboard module not found

Question:

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:CodePython CodeProjectscubingTimer.py", line 1, in <module>
    import keyboard as kbd
ModuleNotFoundError: No module named 'keyboard'

How do i fix this?

Asked By: Illusioner_

||

Answers:

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 worldn")
import keyboard
keyboard.write("Hello worldn")
from keyboard import write
write("Hello worldn")

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

Answered By: Gokul Raghu
Categories: questions Tags:
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.