在树莓派上为 Python3.6 安装 PyQt5

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


我使用的是带有内核版本 4.14.71-v7 的 raspberry pi 3B+,版本 9.4 (lite)。


我使用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

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


那么有没有人知道如何为随后安装的python3.6使用或安装PyQt5?



2019 年 3 月 8 日编辑:感谢 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


有人有想法吗?谢谢你们。


扬帆大鱼
浏览 417回答 3
3回答

慕姐8265434

似乎他们移动了一些东西。就获取事物和编译它们而言,这似乎有效。建造需要很长时间。sudo apt-get updatesudo apt-get install qt5-defaultsudo apt-get install sip-devcd /usr/srcsudo wget https://www.riverbankcomputing.com/static/Downloads/sip/4.19.23/sip-4.19.23.tar.gzsudo tar xzf sip-4.19.23.tar.gzcd sip-4.19.23sudo python3 configure.py --sip-module PyQt5.sipsudo makesudo make installcd /usr/srcsudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/5.13.2/PyQt5-5.13.2.tar.gzsudo tar xzf PyQt5-5.13.2.tar.gzcd PyQt5-5.13.2sudo python3&nbsp; configure.pysudo makesudo make install

偶然的你

由于声誉而无法发表评论,但我会添加到 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 选项。

噜噜哒

今天我找到了解决方案。以下步骤对我有用,没有任何错误。整个过程用了将近两个小时。sudo apt-get updatesudo apt-get install qt5-defaultsudo apt-get install sip-devcd /usr/srcsudo wget https://www.riverbankcomputing.com/static/Downloads/sip/sip-4.19.14.tar.gzsudo tar xzf sip-4.19.14.tar.gzcd sip-4.19.14sudo python3.6 configure.py --sip-module PyQt5.sipsudo makesudo make installcd /usr/srcsudo wget https://www.riverbankcomputing.com/static/Downloads/PyQt5/PyQt5_gpl-5.12.tar.gzsudo tar xzf PyQt5_gpl-5.12.tar.gzcd PyQt5_gpl-5.12sudo python3.6 configure.pysudo makesudo make install
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python