无法在树莓派上安装

无法在树莓派上安装

本文介绍了无法在树莓派上安装 PyQt5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我似乎无法使用以下命令在 raspberry pi 上安装 PyQt5:sudo python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org pyqt5.

I can't seem to install PyQt5 on raspberry pi using:sudo python3 -m pip install --trusted-host pypi.python.org --trusted-host files.pythonhosted.org --trusted-host pypi.org pyqt5.

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

I just have ran out of ideas and am asking here, as i've never seen this error before and i've install PyQt5 the same way on Ubuntu 18.04 with the exact same command and it worked.

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

I have installed countless other packages with the above command and all have been successfull but PyQt5 just doesn't seem to install, I've tried downloading the .tar.gz file manually and installing it manually but it kept throwing errors.

终端错误:

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

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

If it helps this is my raspberry pi's system information stuff:

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

推荐答案

在搜索同样的问题后,我发现了以下有用的帖子:

After searching for the same problem, I came across following usefull posts:

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

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

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

They helped me a lot, and below answer is just a refined version of the original posts above.

以下解决方案适用于我的 Raspberry Pi 3A+ 和 Raspbian Buster 以及 Python 虚拟环境:

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

NOTE: multiple SIP installations can cause errors when importing PyQt5 in python. If below solution does not work, then burn image backup on SD card and try something else. Don't try to install something else on top of non working image.

  1. 进行 SD 卡映像备份

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

NOTE: not all SIP's are compatible with all PyQt5. Read installation documentation to check compatibility.

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

下载所需的SIP源,例如:sip-4.19.14.tar.gzhttps://riverbankcomputing.com/software/sip/download

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

place the archives in convenient directory, for example: /home/pi

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

from terminal go to the directory where archieves are located:

cd/home/pi

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

unzip the archives using:

tar -xzvf PyQt5_gpl-5.12.3.tar.gz

tar -xzvf sip-4.19.14.tar.gz

转到虚拟环境,在我的例子中是cv":

go to virtual environment, in my case it is "cv":

工作简历

安装 QT 核心:

sudo apt-get install qt5-default

配置 SIP:

cd/home/pi/sip-4.19.14

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

构建并安装 SIP make:

build and install SIP make:

制作

sudo make install

配置 PyQt5:

cd/home/pi/PyQt5_gpl-5.12.3

python configure.py

构建并安装 PyQt5 make:

build and install PyQt5 make:

制作

sudo make install

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

NOTE: building PyQt5 make takes 2 hours in Raspberry Pi 3 A+, installing takes another 15 min

这篇关于无法在树莓派上安装 PyQt5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-25 20:00