ImportError: You must be root to use this library on linux.

asked 2021-08-15 11:13:09 -0600

Warmandd gravatar image

I want to read key press in ros noetic, therefore I am using keyboard library from python and I am getting this error. does anyone know what to do?

Traceback (most recent call last):
  File "key.py", line 10, in <module>
    key = keyboard.read_key()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/__init__.py", line 935, in read_key
    event = read_event(suppress)
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/__init__.py", line 924, in read_event
    hooked = hook(queue.put, suppress=suppress)
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/__init__.py", line 461, in hook
    append(callback)
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/_generic.py", line 67, in add_handler
    self.start_if_necessary()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/__init__.py", line 196, in init
    _os_keyboard.init()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/_nixkeyboard.py", line 109, in build_device
    ensure_root()
  File "/home/warman/.local/lib/python3.8/site-packages/keyboard/_nixcommon.py", line 174, in ensure_root
    raise ImportError('You must be root to use this library on linux.')
ImportError: You must be root to use this library on linux.
edit retag flag offensive close merge delete