执行
时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 repo安装pynput。
我在Ubuntu 19.10中使用python版本3.7。
如果我可以提供任何其他信息,请询问。 谢谢!
答案 0 :(得分:1)
我发现的解决方案是将Pynput从1.5降级为1.4.5。看来我的系统不支持1.5。