简体   繁体   English

在树莓派上安装 PyQt5 和 QtDesigner

[英]Install PyQt5 and QtDesigner on Raspberry Pi

Trying to port some code from a PC to a Raspberry Pi.尝试将一些代码从 PC 移植到 Raspberry Pi。 My PC uses the Anaconda distribution, but I'm using the standard Python on the Raspberry Pi.我的 PC 使用 Anaconda 发行版,但我在 Raspberry Pi 上使用标准 Python。

The issue of how to install Qt5 on a Raspberry Pi has been discussed in this question/answer:在这个问题/答案中讨论了如何在树莓派上安装 Qt5 的问题:

Install PyQt5 on Raspberry for Python3.6 在树莓派上为 Python3.6 安装 PyQt5

(The rPi runs Python 3.7, with the 'buster' release) (rPi 运行 Python 3.7,带有“破坏者”版本)

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).我还尝试了'sudo python3 -m pip install pyqt5',它确实下载了,但是生成了一个错误(如下所示)。

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.有趣的是,我能够使用此处的内容安装 PySide2 (5.11.2): https://forum.qt.io/topic/112813/installing-pyside2-on-raspberry-pi但是,这个版本与树莓派略有不同Windows 机器上的一个(5.13.2),因此,复制我遇到的原始代码遇到了一些问题。 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).我的猜测是,如果我可以在 Pi 上安装 QtDesigner,我可以读取 .ui 文件,并在安装后使用 pyside2-uic 生成适当的 Python(我相信它是与 QtDesigner 一起安装的)。

I'm guessing if I can install Qt5, I'll get QtDesigner installed as well.我猜我是否可以安装 Qt5,我也会安装 QtDesigner。

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. 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.此代码不仅安装了 qtcreator,还安装了 Qt5 Assistant、Qt5 Designer 和 Qt5 Linguist。

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

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