[英]the keyboard python library is not working on MacOS Mojave
When I run this code:当我运行此代码时:
import keyboard
def function_that_checks_if_q_is_pressed():
if keyboard.read_key()=="q":
print(True)
while True:
function_that_checks_if_q_is_pressed()
if function_that_checks_if_q_is_pressed==True:
break
break
It gives me this error它给了我这个错误
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/keyboard/__init__.py", line 294, in listen
_os_keyboard.listen(self.direct_callback)
File "/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/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
On another thread, someone said to run the "sudo command" what does that mean?在另一个线程上,有人说运行“sudo 命令”是什么意思?
Thank you谢谢
The "sudo command" basically just runs a command as administrator You just type sudo
followed by the command you would run In your case it looks like your program is trying to do something requiring administrator access When running your program try typing “sudo 命令”基本上只是以管理员身份运行命令您只需键入sudo
,然后键入您将运行的命令在您的情况下,您的程序似乎正在尝试执行需要管理员访问权限的操作运行程序时,请尝试键入
sudo python file.py
Hope this solves your problem:)希望这能解决你的问题:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.