无法导入pynput

Cannot import pynput

执行

import pynput

脚本中的命令,我得到这个:

marc@boop:~$ python3
Python 3.7.5rc1 (default, Oct  8 2019, 16:47:45) 
[GCC 9.2.1 20191008] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pynput
Traceback (most recent call last):
File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_xorg.py",         line 85, in _from_symbol
File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_base.py", line 131, in from_vk
File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_base.py", line     62, in __init__
ValueError: {'is_media': True}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/__init__.py", line 40, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/__init__.py", line 49, in <module>
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_xorg.py", line 105, in <module>
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_xorg.py", line 156, in Key
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_xorg.py", line 102, in _from_media
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_xorg.py", line 90, in _from_symbol
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_base.py", line 131, in from_vk
  File "/usr/local/lib/python3.7/dist-packages/pynput-1.5.0-py3.7.egg/pynput/keyboard/_base.py", line 62, in __init__
ValueError: {'is_media': True}
>>> 

我已经尝试通过 pip 以及 github 存储库安装 pynput。

我在 Ubuntu 19.10 中使用 python 版本 3.7。

如果我可以提供任何其他信息,请询问。 谢谢!

我找到的解决方案是将 pynput 从 1.5 降级到 1.4.5。我的系统似乎不支持 1.5。