Z
Z
Zorroti2021-08-18 13:03:41
Python
Zorroti, 2021-08-18 13:03:41

Why doesn't the keyboard library work?

Hello. I decided to study the keyboard library and wrote the code:

import keyboard as key

if key.is_pressed("space"):
  print("test")


Displays error in console:
Traceback (most recent call last):
File "C:\Python 2021\MyProjects\Keyboard\keyboard.py", line 1, in
import keyboard as key
File "C:\Python 2021\MyProjects\Keyboard\ keyboard.py", line 3, in
if key.is_pressed():
AttributeError: partially initialized module 'keyboard' has no attribute 'is_pressed' (most likely due to a circular import)

Please tell me what the problem is, everything seems to be written correctly .

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question