Python 键盘模块 OsError13
Python Keyboard Module OsError13
我正在努力学习 python。所以我很自然地安装了一些包(bumpy、pandas、sicpy 和 keyboard)。我一直在玩 keyboard
包,但我一直得到 OSError 13
。我见过有人遇到同样的问题,但没有人就如何解决这个问题给出明确的答案。
我环顾了 GitHub 之类的东西。 2018 年的 GitHub 上有一个帖子有同样的问题,但同样没有明确的答案。
这是我不断收到的错误消息:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keyboard/__init__.py", line 292, in listen
_os_keyboard.listen(self.direct_callback)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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
这里是实际的程序代码:
import keyboard # using module keyboard
while True: # making a loop
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('q'): # if key 'q' is pressed
print('You Pressed A Key!')
break # finishing the loop
else:
pass
except:
break # if user pressed a key other than the given key the loop will break
错误信息在代码中。我也是菜鸟,所以如果有人回答了这个问题,如果有人可以 link 回答这个问题。另外:我 运行 在 Mac OS.
上有 IDLE
在终端中,您的代码应该适用于
sudo python3 your_script.py
我正在努力学习 python。所以我很自然地安装了一些包(bumpy、pandas、sicpy 和 keyboard)。我一直在玩 keyboard
包,但我一直得到 OSError 13
。我见过有人遇到同样的问题,但没有人就如何解决这个问题给出明确的答案。
我环顾了 GitHub 之类的东西。 2018 年的 GitHub 上有一个帖子有同样的问题,但同样没有明确的答案。
这是我不断收到的错误消息:
Exception in thread Thread-1:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/keyboard/__init__.py", line 292, in listen
_os_keyboard.listen(self.direct_callback)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/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
这里是实际的程序代码:
import keyboard # using module keyboard
while True: # making a loop
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('q'): # if key 'q' is pressed
print('You Pressed A Key!')
break # finishing the loop
else:
pass
except:
break # if user pressed a key other than the given key the loop will break
错误信息在代码中。我也是菜鸟,所以如果有人回答了这个问题,如果有人可以 link 回答这个问题。另外:我 运行 在 Mac OS.
上有 IDLE在终端中,您的代码应该适用于
sudo python3 your_script.py