python_man
python_man

Reputation: 81

Must be run as administrartor-python

I got this error- I'm a noob because I'm self-taught mostly, nvm

Exception in thread Thread-1:
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
    self.run()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
    self._target(*self._args, **self._kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/keyboard/__init__.py", line 294, in listen
    _os_keyboard.listen(self.direct_callback)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/keyboard/_darwinkeyboard.py", line 430, in listen
    raise OSError("Error 13 - Must be run as administrator")
OSError: Error 13 - Must be run as administrator

my code is just for learning about the keyboard library

import keyboard
while True:
    if keyboard.is_pressed("a"):
        print("yep a!")

Upvotes: 0

Views: 937

Answers (1)

Yeong Jong Lim
Yeong Jong Lim

Reputation: 258

I supposed that you are running your script on a MacOS. If you would like to record keyboard events without application, you will need to grant administrator privilege to your script, by doing the following.

sudo python your-script.py

Upvotes: 2

Related Questions