无法使用`uinput`模块创建设备文件。适用于Windows的Ubuntu上的Python3

时间:2019-03-08 14:45:23

标签: python-3.x ubuntu keyboard windows-subsystem-for-linux uinput

我有一个在python3.4上运行的python脚本,并使用软件包keyboard允许进行键绑定;

keyboard.add_hotkey("enter", self.listener.stop, suppress=True)
keyboard.add_hotkey("shift+enter", self.listener.finish, suppress=True)

当我在Windows上运行此程序时,它可以完美地监听两个热键,并且在Linux(CentOS)上运行时也可以正常工作。

在工作中,我通过Windows 10功能和应用商店在Windows上获得了Ubuntu环境。但是,这种键盘快捷键在此环境中存在问题。

/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/_nixkeyboard.py:110: UserWarning: Failed to create a device file using `uinput` module. Sending of events may be limited or unavailable depending on plugged-in devices.
  device = aggregate_devices('kbd')
Traceback (most recent call last):
  File "main.py", line 32, in <module>
    ], 'test')
  File "/mnt/.../can_controller.py", line 28, in __init__
    self.__initialise_key_handler()
  File "/mnt/.../can_controller.py", line 95, in __initialise_key_handler
    keyboard.add_hotkey("enter", self.listener.stop, suppress=True)
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/__init__.py", line 637, in add_hotkey
    _listener.start_if_necessary()
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/_generic.py", line 35, in start_if_necessary
    self.init()
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/__init__.py", line 194, in init
    _os_keyboard.init()
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/_nixkeyboard.py", line 113, in init
    build_device()
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/_nixkeyboard.py", line 110, in build_device
    device = aggregate_devices('kbd')
  File "/usr/local/lib/python3.6/dist-packages/keyboard-0.13.2-py3.6.egg/keyboard/_nixcommon.py", line 168, in aggregate_devices
    assert fake_device
AssertionError

如果有人知道如何解决此问题或具有良好的解决方法。请让我知道。

0 个答案:

没有答案