【问题标题】:Install PyQt5 on Raspberry for Python3.6在树莓派上安装 PyQt5 for Python3.6
【发布时间】:2021-01-29 13:36:13
【问题描述】:

由于我在较早的帖子和其他论坛中都找不到我的问题的答案,因此我想向 stackoverflow 社区寻求建议。

我使用的是树莓派 3B+,版本 9.4 (lite),内核版本为 4.14.71-v7。

我使用python3.6。我是这样安装的:

sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

cd /usr/src
sudo wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tgz
sudo tar xzf Python-3.6.0.tgz

sudo -s
cd Python-3.6.0
bash configure
make altinstall
exit

安装没有任何问题,一切正常。

现在我想为 python3.6 安装 PyQt5 模块。我通常使用

sudo python3.6 -m pip install ...

用于安装 python3.6 的模块。尝试

sudo python3.6 -m pip install pyqt5

给我错误信息

 Could not find a version that satisfies the requirement PyQt5 (from versions: )
 No matching distribution found for PyQt5

所以我尝试了

sudo apt-get update
sudo apt-get install qt5-default pyqt5-dev pyqt5-dev-tools

但它在树莓上安装了 PyQt5 for python3.5(预装)。

那么有谁知道如何使用或安装 PyQt5 以供后续安装 python3.6?

编辑 08.03.2019:
感谢 FlyingTeller。我开始从源代码构建。我按照以下步骤操作 你的链接。

sudo apt-get update
cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
sudo tar xzf sip-4.19.14.tar.gz
cd sip-4.19.14
sudo -s
python3.6 configure.py --sip-module=PyQt5.sip 
make
make install

cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gz
sudo tar xzf PyQt5_gpl-5.12.tar.gz
cd PyQt5_gpl-5.12
python3.6 configure.py

然后我收到以下错误

Error: Use the --qmake argument to explicitly specify a working Qt qmake.

我认为我在正确的道路上,但我不明白 qmake 是什么或它是什么 意思。

编辑 10.03.2019:
我可以解决最后一条错误消息。我安装了

sudo apt-get install qt5-default

然后我做了与已经提到的相同的程序。现在我得到错误

fatal error: sip.h: File or directory not found 
#include <sip.h>

PyQt5 config.py 位于:/usr/src/PyQt5_gpl-5.12
SIP sip.h 在:/usr/src/sip-4.19.14

有人有想法吗?谢谢大家。

【问题讨论】:

  • 你在用virtualenv
  • 你考虑过building from source吗?
  • 我正在尝试,但还没有奏效。查看修改。

标签: python installation pyqt5 raspberry-pi3


【解决方案1】:

今天我找到了解决方案。以下步骤对我有用,没有任何错误。整个过程花了将近两个小时。

sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install sip-dev

cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gz
sudo tar xzf sip-4.19.14.tar.gz
cd sip-4.19.14
sudo python3.6 configure.py --sip-module PyQt5.sip
sudo make
sudo make install

cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gz
sudo tar xzf PyQt5_gpl-5.12.tar.gz
cd PyQt5_gpl-5.12
sudo python3.6 configure.py
sudo make
sudo make install

【讨论】:

  • 你最好使用“sudo make -j4”
  • 为什么这样更好?
  • 使用“-j4”标志会提高安装速度。
【解决方案2】:

好像他们搬了一些东西。就获取东西并编译它们而言,这似乎有效。构建需要很长时间。

对于相关的设计师,请看:

QtDesigner for Raspberry Pi

sudo apt-get update
sudo apt-get install qt5-default
sudo apt-get install sip-dev

cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.23/sip-4.19.23.tar.gz
sudo tar xzf sip-4.19.23.tar.gz
cd sip-4.19.23
sudo python3 configure.py --sip-module PyQt5.sip
sudo make
sudo make install

cd /usr/src
sudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/5.13.2/PyQt5-5.13.2.tar.gz
sudo tar xzf PyQt5-5.13.2.tar.gz
cd PyQt5-5.13.2
sudo python3  configure.py
sudo make
sudo make install

【讨论】:

    【解决方案3】:

    在我的情况下,它有助于将 pip 从版本 18 更新到最新版本,在我的情况下为 20.2 (python -m pip install --upgrade pip),然后执行pip install PyQt5

    【讨论】:

      【解决方案4】:

      接受的答案中使用的说明对我不起作用。我认为这仅仅是因为它们已经过时了。我想发布 确实 对我有用的命令列表。截至 2020 年 12 月 20 日,我正在使用最新版本的 Raspbian 运行 Pi 400。我使用默认的python3 而不是python3.6

      这是对我有用的修改后的命令列表:

      sudo apt-get install qt5-default
      sudo apt-get install sip-dev
      
      cd /usr/src
      sudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-5.5.1.dev2011271026.tar.gz
      sudo tar xzf sip-5.5.1.dev2011271026.tar.gz
      cd sip-5.5.1.dev2011271026
      sudo python3 setup.py build
      sudo python3 setup.py install
      
      sudo wget https://files.pythonhosted.org/packages/28/6c/640e3f5c734c296a7193079a86842a789edb7988dca39eab44579088a1d1/PyQt5-5.15.2.tar.gz
      sudo tar xzf PyQt5-5.15.2.tar.gz
      cd PyQt5-5.15.2
      sudo python3 configure.py
      sudo make
      sudo make install
      
      

      【讨论】:

        【解决方案5】:

        由于声誉问题无法发表评论,但我会添加到 Christ Troutner 有用的更新答案,如果用户收到 No module named 'PyQt5.sip' 错误,请在配置期间尝试 --sip-module PyQt5.sip,根据文档:

        注意

        在构建 PyQt5 v5.11 或更高版本时,您必须配置 SIP 以创建一个 sip 模块的私有副本,使用类似于 以下:

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

        如果您已经安装了 SIP,并且只想构建和 安装模块的私有副本,然后添加 --no-tools 选项。

        【讨论】:

          【解决方案6】:

          接受的答案对我不起作用,下面是对我有用的代码。

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

          此代码不仅安装 Qtcreator,还安装 Qt5 Assistant、Qt5 Designer 和 Qt5 Linguist

          【讨论】:

            猜你喜欢
            • 2020-10-29
            • 1970-01-01
            • 2020-04-15
            • 2021-01-18
            • 1970-01-01
            • 1970-01-01
            • 2015-12-10
            • 2021-01-23
            • 1970-01-01
            相关资源
            最近更新 更多