繁体   English   中英

无法在树莓派上安装 PyQt5

[英]Can't install PyQt5 On Raspberry pi

我似乎无法使用以下方法在树莓派上安装PyQt5sudo python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org pyqt5

我只是没有想法,所以我在这里问,因为我以前从未见过这个错误,我已经使用完全相同的命令在 Ubuntu 18.04 上以相同的方式安装了PyQt5并且它有效。

我已经使用上述命令安装了无数其他软件包并且都成功了但是PyQt5似乎没有安装,我尝试手动下载.tar.gz文件并手动安装它但它一直抛出错误。

终端错误:

pi@raspberrypi:~/Desktop $ sudo python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org pyqt5
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyqt5
/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/pyqt5/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/pyqt5/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/pyqt5/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/pyqt5/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError(SSLError("bad handshake: Error([('SSL routines', 'tls_process_server_certificate', 'certificate verify failed')])"))': /simple/pyqt5/
/usr/share/python-wheels/urllib3-1.24.1-py2.py3-none-any.whl/urllib3/connectionpool.py:849: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  Downloading https://files.pythonhosted.org/packages/7c/5b/e760ec4f868cb77cee45b4554bf15d3fe6972176e89c4e3faac941213694/PyQt5-5.14.0.tar.gz (3.2MB)
    100% |████████████████████████████████| 3.2MB 818kB/s 
  Installing build dependencies ... error
  Complete output from command /usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-rrmt_pc2 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org -- "sip >=5.0.1 <6" "PyQt-builder >=1.1.0, <2":
  Invalid requirement: 'sip >=5.0.1 <6'
  Traceback (most recent call last):
    File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/requirements.py", line 93, in __init__
      req = REQUIREMENT.parseString(requirement_string)
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1632, in parseString
      raise exc
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1622, in parseString
      loc, tokens = self._parse( instring, 0 )
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
      loc,tokens = self.parseImpl( instring, preloc, doActions )
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3395, in parseImpl
      loc, exprtokens = e._parse( instring, loc, doActions )
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1383, in _parseNoCache
      loc,tokens = self.parseImpl( instring, preloc, doActions )
    File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3183, in parseImpl
      raise ParseException(instring, loc, self.errmsg, self)
  pyparsing.ParseException: Expected stringEnd (at char 12), (line:1, col:13)

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/lib/python3/dist-packages/pip/_internal/req/constructors.py", line 253, in install_req_from_line
      req = Requirement(req)
    File "/usr/share/python-wheels/packaging-19.0-py2.py3-none-any.whl/packaging/requirements.py", line 97, in __init__
      requirement_string[e.loc : e.loc + 8], e.msg
  pip._vendor.packaging.requirements.InvalidRequirement: Parse error at "'<6'": Expected stringEnd


  ----------------------------------------
Command "/usr/bin/python3 -m pip install --ignore-installed --no-user --prefix /tmp/pip-build-env-rrmt_pc2 --no-warn-script-location --no-binary :none: --only-binary :none: -i https://pypi.org/simple --extra-index-url https://www.piwheels.org/simple --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org -- "sip >=5.0.1 <6" "PyQt-builder >=1.1.0, <2"" failed with error code 1 in None

如果有帮助,这是我的树莓派的系统信息:

pi@raspberrypi:~/Downloads $ uname -a
Linux raspberrypi 4.19.75-v7+ #1270 SMP Tue Sep 24 18:45:11 BST 2019 armv7l GNU/Linux

搜索同样的问题后,我遇到了以下有用的帖子:

https://raspberrypi.stackexchange.com/questions/62939/pyqt5-on-a-raspberry-pi

PyQt5 错误“PyCapsule_GetPointer 调用的名称不正确”

他们帮了我很多,下面的答案只是上面原始帖子的精炼版本。

下面的解决方案适用于我的 Raspberry Pi 3A+ 与 Raspbian Buster 和 python 虚拟环境:

注意:在 python 中导入 PyQt5 时,多个 SIP 安装可能会导致错误。 如果以下解决方案不起作用,则在 SD 卡上刻录映像备份并尝试其他方法。 不要尝试在非工作图像上安装其他东西。

  1. 进行 SD 卡映像备份

注意:并非所有 SIP 都与所有 PyQt5 兼容。 阅读安装文档以检查兼容性。

  1. 下载所需的 PyQt5 源码,例如:PyQt5_gpl-5.12.3.tar.gz from https://riverbankcomputing.com/software/pyqt/download5

  2. 下载需要的SIP源,例如:sip-4.19.14.tar.gz from https://riverbankcomputing.com/software/sip/download

  3. 将档案放在方便的目录中,例如:/home/pi

  4. 从终端转到存档所在的目录:

    cd /home/pi

  5. 使用以下方法解压缩档案:

    tar -xzvf PyQt5_gpl-5.12.3.tar.gz

    tar -xzvf sip-4.19.14.tar.gz

  6. 转到虚拟环境,在我的情况下是“cv”:

    workon cv

  7. 安装 QT 核心:

    sudo apt-get install qt5-default

  8. 配置SIP:

    cd /home/pi/sip-4.19.14

    python configure.py --sip-module PyQt5.sip

  9. 构建和安装 SIP 制作:

    make

    sudo make install

  10. 配置 PyQt5:

    cd /home/pi/PyQt5_gpl-5.12.3

    python configure.py

  11. 构建和安装 PyQt5 制作:

    make

    sudo make install

注意:在 Raspberry Pi 3 A+ 中构建 PyQt5 make 需要 2 小时,安装需要另外 15 分钟

我得到了同样的错误。 就我而言,我试图安装一个依赖 PyQt5 的程序。 最后我可以通过执行以下操作来解决它:

  1. 创建一个虚拟环境并激活它:

    python3 -m venv venv source venv/bin/activate

  2. 重新安装放置在虚拟环境中的默认 pip。 在我将 pip 从 v9.0.1 升级到 pip-20.0.2 的情况下:

    pip install --upgrade pip

  3. (重新)安装您的软件

    pip install <your software>

而不是使用 pip 来安装 PyQt5;

sudo apt-get install python3-PyQt5

为我工作。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM