簡體   English   中英

在樹莓派上為 Python3.6 安裝 PyQt5

[英]Install PyQt5 on Raspberry for Python3.6

由於我在較舊的帖子和其他論壇中都沒有找到我的問題的答案,因此我想向 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 日編輯:
謝謝飛特勒。 我開始從源代碼構建。 我按照您鏈接中的步驟操作。

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 是什么或它意味着什么。

2019 年 3 月 10 日編輯:
我可以解決最后一條錯誤消息。 我安裝了

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

有人有想法嗎? 謝謝你們。

今天我找到了解決方案。 以下步驟對我有用,沒有任何錯誤。 整個過程用了將近兩個小時。

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

似乎他們移動了一些東西。 就獲取事物和編譯它們而言,這似乎有效。 建造需要很長時間。

對於相關的設計師,請看:

用於 Raspberry Pi 的 QtDesigner

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

我嘗試按照您的步驟操作,但收到錯誤消息:我安裝了python 3.7.0,因此我進行了相應的更改,現在我在sip上安裝了版本5,因此當我嘗試“ sudo python3.6 configure.py --sip-模塊PyQt5.sip”我得到“沒有這樣的文件或目錄” ...任何幫助或想法?

在我的情況下,它有助於將 pip 從 verion 18 更新到最新版本,在我的情況下是 20.2 ( python -m pip install --upgrade pip ),然后執行pip install PyQt5

接受的答案中使用的說明對我不起作用。 我認為這僅僅是因為它們已經過時了。 我想張貼沒有工作對我的命令列表。 截至 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

由於聲譽而無法發表評論,但我會添加到 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 update
   sudo apt-get install qt5-default
   sudo apt-get install qtcreator

這段代碼不僅安裝了Qtcreator,還安裝了Qt5 Assistant、Qt5 Designer和Qt5 Linguist

謝謝你的這個話題。 我正在聽你的指示。 但是在我安裝代碼/程序時,安裝完成后,出現以下錯誤:

=================================

qt5ct:使用qt5ct插件QEGLPlatformContext:創建上下文失敗:3009

QOpenGLWindow :: beginPaint:無法創建上下文

QOpenGLWindow :: beginPaint:無法使上下文為當前

追溯(最近一次通話):

在initializeGL中的文件“ my_prog.py”,第68行

self.gl = self.context().versionFunctions()

AttributeError:模塊“ PyQt5._QOpenGLFunctions_ES2”沒有屬性“ QOpenGLFunctions_ES2”

中止

=================================

你有解決的辦法嗎? 提前謝謝了。

我正在使用默認情況下具有python3.7的Raspberry Pi4。 我安裝了python3.6,並按照您的確切說明進行操作(在python3.7上也收到了相同的消息)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM