【发布时间】:2021-11-07 22:51:31
【问题描述】:
我正在尝试使用 pip install pynput 安装 pynput 并像这样输出
$ pip install pynput
Collecting pynput
Using cached pynput-1.7.3-py2.py3-none-any.whl (99 kB)
Requirement already satisfied: python-xlib>=0.17 in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pynput) (0.31)
Requirement already satisfied: six in /data/data/com.termux/files/usr/lib/python3.9/site-packages (from pynput) (1.16.0)
Collecting evdev>=1.3
Using cached evdev-1.4.0.tar.gz (26 kB)
Using legacy 'setup.py install' for evdev, since package 'wheel' is not installed.
Installing collected packages: evdev, pynput
Running setup.py install for evdev ... error
ERROR: Command errored out with exit status 1:
command: /data/data/com.termux/files/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-a4x3o5ji/evdev_c26c21c2fb7741e49333f8636dfc1cb0/setup.py'"'"'; __file__='"'"'/data/data/com.termux/files/usr/tmp/pip-install-a4x3o5ji/evdev_c26c21c2fb7741e49333f8636dfc1cb0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /data/data/com.termux/files/usr/tmp/pip-record-56ud8l4q/install-record.txt --single-version-externally-managed --compile --install-headers /data/data/com.termux/files/usr/include/python3.9/evdev
cwd: /data/data/com.termux/files/usr/tmp/pip-install-a4x3o5ji/evdev_c26c21c2fb7741e49333f8636dfc1cb0/
Complete output (37 lines):
running install
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.9
creating build/lib.linux-aarch64-3.9/evdev
copying evdev/__init__.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/device.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/ecodes.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/eventio.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/eventio_async.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/events.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/evtest.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/ff.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/genecodes.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/uinput.py -> build/lib.linux-aarch64-3.9/evdev
copying evdev/util.py -> build/lib.linux-aarch64-3.9/evdev
running build_ext
running build_ecodes
The 'linux/input.h' and 'linux/input-event-codes.h' include files
are missing. You will have to install the kernel header files in
order to continue:
yum install kernel-headers-$(uname -r)
apt-get install linux-headers-$(uname -r)
emerge sys-kernel/linux-headers
pacman -S kernel-headers
In case they are installed in a non-standard location, you may use
the '--evdev-headers' option to specify one or more colon-separated
paths. For example:
python setup.py \
build \
build_ecodes --evdev-headers path/input.h:path/input-event-codes.h \
build_ext --include-dirs path/ \
install
----------------------------------------
ERROR: Command errored out with exit status 1: /data/data/com.termux/files/usr/bin/python3 -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/data/data/com.termux/files/usr/tmp/pip-install-a4x3o5ji/evdev_c26c21c2fb7741e49333f8636dfc1cb0/setup.py'"'"'; __file__='"'"'/data/data/com.termux/files/usr/tmp/pip-install-a4x3o5ji/evdev_c26c21c2fb7741e49333f8636dfc1cb0/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /data/data/com.termux/files/usr/tmp/pip-record-56ud8l4q/install-record.txt --single-version-externally-managed --compile --install-headers /data/data/com.termux/files/usr/include/python3.9/evdev Check the logs for full command output.
【问题讨论】:
-
Linux, OSX and w32 是唯一受支持的平台。我怀疑即使在 Termux 中它也能在 Android 上运行。
-
Termux 中有x11-repo。我在 Termux 上成功安装了
pynput和evdev,但我不确定它们是否会工作,仍在测试中。要安装evdev,您必须指定运行setup.py时Linux 内核头文件(input.h、input-event-codes.h)的位置,如evdev doc 中所指定。为此,首先通过uname -a查找内核版本。然后从kernel.org下载并提取内核代码。 -
evdev在我的 Android 设备上工作。我能够读写触摸屏事件。我没有在 Termux 上使用图形环境,所以我不打算测试pynput。我想它也会起作用。