Can't install PyQt5 On Raspberry pi

隐身守侯 提交于 2021-02-17 06:36:25

问题


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.

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.

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.

Terminal Error:

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

回答1:


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

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

PyQt5 error "PyCapsule_GetPointer called with incorrect name"

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

Below solution worked on my Raspberry Pi 3A+ with Raspbian Buster and virtual environment for python:

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. take SD card image backup

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

  1. download required PyQt5 source, for example: PyQt5_gpl-5.12.3.tar.gz from https://riverbankcomputing.com/software/pyqt/download5

  2. download required SIP source, for example: sip-4.19.14.tar.gz from https://riverbankcomputing.com/software/sip/download

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

  4. from terminal go to the directory where archieves are located:

    cd /home/pi

  5. unzip the archives using:

    tar -xzvf PyQt5_gpl-5.12.3.tar.gz

    tar -xzvf sip-4.19.14.tar.gz

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

    workon cv

  7. install QT Core:

    sudo apt-get install qt5-default

  8. configure SIP:

    cd /home/pi/sip-4.19.14

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

  9. build and install SIP make:

    make

    sudo make install

  10. configure PyQt5:

    cd /home/pi/PyQt5_gpl-5.12.3

    python configure.py

  11. build and install PyQt5 make:

    make

    sudo make install

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




回答2:


I got the same error. In my case I was trying to install a program that depends on PyQt5. Finally I could solve it by doing:

  1. Create a virtual environment and activate it:

    python3 -m venv venv source venv/bin/activate

  2. Reinstall the default pip that was put inside the virtual environment. In my case that upgrades pip from v9.0.1 to pip-20.0.2:

    pip install --upgrade pip

  3. (re-)Install your software

    pip install <your software>



来源:https://stackoverflow.com/questions/59558343/cant-install-pyqt5-on-raspberry-pi

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!