【问题标题】:Can't install Pip package on Raspberry PI 4 (adafruit_circuitpython_neopixel)无法在 Raspberry PI 4 上安装 Pip 包(adafruit_circuitpython_neopixel)
【发布时间】:2021-07-11 23:01:48
【问题描述】:

我正在尝试在运行 Raspbian Buster / RetroPi 的 Raspberry Pi 4 上安装上述库。

安装程序收集包,然后在setup.py 上失败,说明:

* Setup can't determine the value of PAGE_SIZE on your system, so it will
    * default to 4096 which may not be correct.

尝试了更多诊断/故障排除:

  • 我之前在 Raspberry Pi 3 上安装了相同的软件包,没有问题(我认为它也在运行 Buster)
  • 我已经成功地使用pip3 installtornadocolorzero 等在 Pi 4 上安装了其他 python 包。
  • 我已经运行 sudo apt update && sudo apt upgrade + 重新启动 - 没有帮助
  • 我试过 python 2 (pip install pip install adafruit-circuitpython-neopixel) - 同样的错误

任何帮助将不胜感激 - 谢谢!

完全错误:

pip3 install adafruit-circuitpython-neopixel
Defaulting to user installation because normal site-packages is not writeable
Collecting adafruit-circuitpython-neopixel
  Using cached adafruit-circuitpython-neopixel-6.0.3.tar.gz (28 kB)
Collecting Adafruit-Blinka
  Using cached Adafruit-Blinka-6.4.2.tar.gz (122 kB)
Collecting adafruit-circuitpython-pypixelbuf>=2.0.0
  Using cached adafruit-circuitpython-pypixelbuf-2.2.4.tar.gz (28 kB)
Collecting Adafruit-PlatformDetect>=3.1.0
  Using cached Adafruit-PlatformDetect-3.5.0.tar.gz (29 kB)
Collecting Adafruit-PureIO>=1.1.7
  Using cached Adafruit_PureIO-1.1.8.tar.gz (26 kB)
Collecting pyftdi>=0.40.0
  Using cached pyftdi-0.52.9-py3-none-any.whl (139 kB)
Requirement already satisfied: RPi.GPIO in /usr/lib/python3/dist-packages (from Adafruit-Blinka->adafruit-circuitpython-neopixel) (0.7.0)
Collecting rpi_ws281x>=4.0.0
  Using cached rpi_ws281x-4.2.6.tar.gz (63 kB)
Collecting sysv_ipc>=1.1.0
  Using cached sysv_ipc-1.1.0.tar.gz (99 kB)
Requirement already satisfied: pyusb>=1.0.0 in /usr/local/lib/python3.7/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-neopixel) (1.1.1)
Requirement already satisfied: pyserial>=3.0 in /usr/local/lib/python3.7/dist-packages (from pyftdi>=0.40.0->Adafruit-Blinka->adafruit-circuitpython-neopixel) (3.5)
Using legacy 'setup.py install' for adafruit-circuitpython-neopixel, since package 'wheel' is not installed.
Using legacy 'setup.py install' for adafruit-circuitpython-pypixelbuf, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Adafruit-Blinka, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Adafruit-PlatformDetect, since package 'wheel' is not installed.
Using legacy 'setup.py install' for Adafruit-PureIO, since package 'wheel' is not installed.
Using legacy 'setup.py install' for rpi-ws281x, since package 'wheel' is not installed.
Using legacy 'setup.py install' for sysv-ipc, since package 'wheel' is not installed.
Installing collected packages: sysv-ipc, rpi-ws281x, pyftdi, Adafruit-PureIO, Adafruit-PlatformDetect, Adafruit-Blinka, adafruit-circuitpython-pypixelbuf, adafruit-circuitpython-neopixel
    Running setup.py install for sysv-ipc ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9qk3bog7/sysv-ipc_2c9b66fe81a04f5c99cf319aff553101/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9qk3bog7/sysv-ipc_2c9b66fe81a04f5c99cf319aff553101/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d842td8m/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/pi/.local/include/python3.7m/sysv-ipc
         cwd: /tmp/pip-install-9qk3bog7/sysv-ipc_2c9b66fe81a04f5c99cf319aff553101/
    Complete output (19 lines):
    ******************************************************************************
    * Setup can't determine the value of PAGE_SIZE on your system, so it will
    * default to 4096 which may not be correct.
    *
    * Please report this message and your operating system info to the package
    * maintainer listed in the README file.
    ******************************************************************************
    running install
    running build
    running build_ext
    building 'sysv_ipc' extension
    creating build
    creating build/temp.linux-armv7l-3.7
    arm-linux-gnueabihf-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.7m -c sysv_ipc_module.c -o build/temp.linux-armv7l-3.7/sysv_ipc_module.o
    sysv_ipc_module.c:32:10: fatal error: Python.h: No such file or directory
     #include "Python.h"
              ^~~~~~~~~~
    compilation terminated.
    error: command 'arm-linux-gnueabihf-gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9qk3bog7/sysv-ipc_2c9b66fe81a04f5c99cf319aff553101/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9qk3bog7/sysv-ipc_2c9b66fe81a04f5c99cf319aff553101/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-d842td8m/install-record.txt --single-version-externally-managed --user --prefix= --compile --install-headers /home/pi/.local/include/python3.7m/sysv-ipc Check the logs for full command output.

【问题讨论】:

  • Mods - 我不确定这是否更适合 Rpi 站点,因为它主要是关于 Python 包,但它可能特定于 Rpi。如果您认为合适,请随意移动它。
  • 完整的错误回溯?
  • 对了,忘记贴了,抱歉。编辑帖子以包含它。
  • 你试过pip3 install wheel然后再尝试安装吗?
  • 如果这不起作用,请尝试sudo apt install python3-dev,然后再次尝试安装。

标签: python pip raspberry-pi4


【解决方案1】:

SuperStormer 建议 sudo apt install python3-dev - 成功了!

我不知道为什么会这样,因为This post 暗示它的用途是用于 Python 扩展,而不是常规库。

它显然包含 Python C 头文件,因此库可能出于某种原因需要这些头文件。

【讨论】:

  • 要构建库,它需要 C 头文件(因为您需要构建 C 程序,并且 python 支持 C 扩展)。在 Windows 上,您可以使用 Visual Studio 获得它们。在 Linux 上,您显然可以使用sudo apt install python3-dev 获得它们。每天学习新东西!
  • “Python 扩展”是指使用 Python 扩展 API 以其他语言(如 C 和 C++)实现的库位:docs.python.org/3/extending/extending.html - 如果没有可用于的轮子(预编译)一个你需要的包,然后你必须从源代码编译(如果有的话) - pip 为你工作,但你需要有 python3-dev 和包在构建时需要的任何其他构建依赖项。
【解决方案2】:

确保 pip 使用 piwheels.org 作为附加索引 - piwheels 为所有包构建预编译的轮子,因此您不必自己编译它们。

标准 Raspberry Pi OS 通过添加 /etc/pip.conf 来预先配置 pip 以使用它:

[global]
extra-index-url=https://www.piwheels.org/simple

或者,在您的 pip 命令中指定它,例如:

pip3 install xxx --extra-index-url https://www.piwheels.org/simple

您可以在piwheels.org 阅读更多内容并查看特定包

【讨论】:

    猜你喜欢
    • 2021-03-20
    • 2019-02-24
    • 1970-01-01
    • 2015-10-07
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    • 2021-12-14
    • 1970-01-01
    相关资源
    最近更新 更多