简体   繁体   中英

Install PyQt5 and QtDesigner on Raspberry Pi

Trying to port some code from a PC to a Raspberry Pi. My PC uses the Anaconda distribution, but I'm using the standard Python on the Raspberry Pi.

The issue of how to install Qt5 on a Raspberry Pi has been discussed in this question/answer:

Install PyQt5 on Raspberry for Python3.6

(The rPi runs Python 3.7, with the 'buster' release)

I tried running through the commands from the original installation, but I believe some of the links are broken. I also tried 'sudo python3 -m pip install pyqt5', which did download, however, an error is generated (as shown below).

Interestingly enough, I was able install PySide2 (5.11.2) using what is here: https://forum.qt.io/topic/112813/installing-pyside2-on-raspberry-pi However, this version is slightly different than the one (5.13.2) on a Windows machine, and therefore, copying the original code I had runs into some problems. My guess is that if I can install QtDesigner on the Pi, I can read the.ui file, and generate the appropriate Python with pyside2-uic, once it is installed (which installed with QtDesigner, I believe).

I'm guessing if I can install Qt5, I'll get QtDesigner installed as well.

pi@raspberrypi:~/Desktop $ sudo python3 -m pip install pyqt5
Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
Collecting pyqt5
  Using cached https://files.pythonhosted.org/packages/8c/90/82c62bbbadcca98e8c6fa84f1a638de1ed1c89e85368241e9cc43fcbc320/PyQt5-5.15.0.tar.gz
  Installing build dependencies ... done
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.7/tokenize.py", line 447, in open
        buffer = _builtin_open(filename, 'rb')
    FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-install-x2es80xb/pyqt5/setup.py'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-install-x2es80xb/pyqt5/
pi@raspberrypi:~/Desktop $ python3
Python 3.7.3 (default, Dec 20 2019, 18:57:59) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

You can try steps mentioned below. It will take time on Raspberry Pi.

sudo apt-get install qt5-default

wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.24/sip-4.19.24.tar.gz

tar -xzvf sip-4.19.24.tar.gz

cd sip-4.19.24

python configure.py

make

make install

cd ../

wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5-5.15.1.dev2008081558.tar.gz

tar -xzvf PyQt5-5.15.1.dev2008081558.tar.gz

cd PyQt5-5.15.1.dev2008081558

python configure.py

make

make install

pip install PyQt5-sip

The above answers did not work for me, below is the code that worked for me.

       sudo apt-get update
       sudo apt-get install qt5-default
       sudo apt-get install qtcreator

This code not only installs qtcreator but also installs Qt5 Assistant, Qt5 Designer, and Qt5 Linguist.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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