【问题标题】:Installing pynput results in ERROR: Command errored out with exit status 1安装 pynput 导致 ERROR: Command errored out with exit status 1
【发布时间】: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 上成功安装了pynputevdev,但我不确定它们是否会工作,仍在测试中。要安装evdev,您必须指定运行setup.py 时Linux 内核头文件(input.hinput-event-codes.h)的位置,如evdev doc 中所指定。为此,首先通过uname -a 查找内核版本。然后从kernel.org下载并提取内核代码。
  • evdev 在我的 Android 设备上工作。我能够读写触摸屏事件。我没有在 Termux 上使用图形环境,所以我不打算测试 pynput。我想它也会起作用。

标签: python pip pynput termux


【解决方案1】:
  1. 通过uname -auname -r 或其他方式查看内核版本。
$ uname -r
4.4.153-perf+
  1. kernel.org 下载并提取内核源代码。
$ wget https://mirrors.edge.kernel.org/pub/linux/kernel/v4.x/linux-4.4.153.tar.gz
$ tar -xf linux-4.4.153.tar.gz
  1. 下载并解压evdev source
$ wget https://files.pythonhosted.org/packages/4d/ec/bb298d36ed67abd94293253e3e52bdf16732153b887bf08b8d6f269eacef/evdev-1.4.0.tar.gz
$ tar -xf evdev-1.4.0.tar.gz && cd evdev-1.4.0
  1. 构建并安装evdev
python setup.py build \
    build_ecodes --evdev-headers /data/data/com.termux/files/home/linux-4.4.153/include/uapi/linux/input.h:/data/data/com.termux/files/home/linux-4.4.153/include/uapi/linux/input-event-codes.h:/data/data/com.termux/files/home/linux-4.4.153/include/uapi/linux/uinput.h \
    build_ext install
  1. pip install pynput

这适用于我的设备。我可以使用evdev 读写触摸屏事件。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,但这对我有用:

    python -m pip install pynput

    【讨论】:

    • 在安卓系统上?在 Termux 中?
    • 但是你能在Termux中成功安装pynput吗?不信,pynput 和安卓不兼容,Termux 也没有提供足够的类 Linux 环境; Linux 上的pynput 需要 XWin,而 Termux 不提供。那么让我重复一下我的问题:您在 Termux 中在 Android 上完成了python -m pip install pynput 并且安装成功了吗?
    • 不,我在我的 Ubuntu 上这样做了,然后我尝试了 python -m pip install pynput 并成功安装!
    猜你喜欢
    • 2020-10-04
    • 2020-09-24
    • 1970-01-01
    • 1970-01-01
    • 2011-08-20
    • 2015-11-09
    • 1970-01-01
    • 2020-10-13
    • 2019-03-19
    相关资源
    最近更新 更多