简体   繁体   English

如何使用 QtWebEngine 在 Raspberry Pi 上安装 PySide2 / PyQt5?

[英]How to install PySide2 / PyQt5 on Raspberry Pi with QtWebEngine?

I am aware it is possible to install PySide2 on Raspbian using the following command:我知道可以使用以下命令在 Raspbian 上安装 PySide2:

sudo apt-get install python3-pyside2.qt3dcore python3-pyside2.qt3dinput python3-pyside2.qt3dlogic python3-pyside2.qt3drender python3-pyside2.qtcharts python3-pyside2.qtconcurrent python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qthelp python3-pyside2.qtlocation python3-pyside2.qtmultimedia python3-pyside2.qtmultimediawidgets python3-pyside2.qtnetwork python3-pyside2.qtopengl python3-pyside2.qtpositioning python3-pyside2.qtprintsupport python3-pyside2.qtqml python3-pyside2.qtquick python3-pyside2.qtquickwidgets python3-pyside2.qtscript python3-pyside2.qtscripttools python3-pyside2.qtsensors python3-pyside2.qtsql python3-pyside2.qtsvg python3-pyside2.qttest python3-pyside2.qttexttospeech python3-pyside2.qtuitools python3-pyside2.qtwebchannel python3-pyside2.qtwebsockets python3-pyside2.qtwidgets python3-pyside2.qtx11extras python3-pyside2.qtxml python3-pyside2.qtxmlpatterns python3-pyside2uic

However, this doesn't include QtWebEngine and I cannot seem to find a package like python3-pyside2.qtwebengine either.但是,这不包括 QtWebEngine,我似乎也找不到像 python3-pyside2.qtwebengine 这样的包。 Same goes for PyQt5 which I could use alternatively, but it does not exist there either.我可以替代使用的 PyQt5 也是如此,但它也不存在。

So my question is: Is there any way to run my Python application, which uses QtWebEngine, on my Raspberry Pi (Raspbian 10 "Buster")?所以我的问题是:有什么方法可以在我的 Raspberry Pi(Raspbian 10 “Buster”)上运行我使用 QtWebEngine 的 Python 应用程序? Also I have 6 Pi's which need to run the application.我还有 6 个 Pi 需要运行应用程序。 So if the only solution is to build from source, is there a way to build on one machine and then distribute it to the others without recompiling?因此,如果唯一的解决方案是从源代码构建,有没有办法在一台机器上构建,然后将其分发给其他机器而无需重新编译?

Another consideration is to use QWebView instead of QWebEngineView because that seems to be available through QtWebKit at least for PyQt5 (package python3-pyqt5.qtwebkit).另一个考虑是使用 QWebView 而不是 QWebEngineView 因为这似乎可以通过 QtWebKit 至少用于 PyQt5(包 python3-pyqt5.qtwebkit)。 Would that work?那行得通吗? Is it okay to work-around the issue despite the fact that QtWebKit is deprecated?尽管 QtWebKit 已被弃用,是否可以解决该问题? Also I have the problem, that on my windows machine QtWebKit is NOT included within the PyQt5 package, nor does the seperate PyQtWebKit PyPl package work, so it would be hard to code/debug the tool as I would always have to move it to the raspi first... So however I put it, there is always something which is inconvinient...我还有一个问题,在我的 Windows 机器上,QtWebKit 不包含在 PyQt5 包中,单独的 PyQtWebKit PyPl 包也不工作,所以很难对工具进行编码/调试,因为我总是必须将它移动到raspi first...所以不管我怎么说,总有一些不方便的东西...

So I finally found the solution myself.所以我终于自己找到了解决方案。 From what I understand, the reason you cannot find QtWebEngine in the Raspberry Pi OS repositories, is that the Pi OS is made to run on all Raspberry Pi's, including Pi 1 and Pi 2, which have an ARMv6 and ARMv7 CPU architecture respectively.据我了解,在 Raspberry Pi OS 存储库中找不到 QtWebEngine 的原因是 Pi OS 可以在所有 Raspberry Pi 上运行,包括分别具有 ARMv6 和 ARMv7 CPU 架构的 Pi 1 和 Pi 2。 The WebEngine module however is platform dependend and not tested, compiled and distributed for ARMv6/7 anymore, so they won't release it in the repositories for Raspberry Pi OS.然而,WebEngine 模块是平台相关的,不再针对 ARMv6/7 进行测试、编译和分发,因此他们不会在 Raspberry Pi OS 的存储库中发布它。 Luckily though, the Raspberry Pi 3 that I use has ARMv8, so it is possible to install QtWebEngine from Debian repositories , which offer QtWebEngine for exactly that architecture.幸运的是,我使用的Raspberry Pi 3具有 ARMv8,因此可以从 Debian 存储库安装 QtWebEngine ,它为该架构提供 QtWebEngine。 Here is how:方法如下:

Open your sources.list file打开你的sources.list文件

sudo nano /etc/apt/source.list

Add the following line and save/close:添加以下行并保存/关闭:

deb http://deb.debian.org/debian/ buster main

Now update your package list现在更新您的包裹清单

sudo apt update

It is possible that you encounter some errors concerning missing public keys, which we will now validate through a keyserver:您可能会遇到一些关于缺少公钥的错误,我们现在将通过密钥服务器进行验证:

sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 648ACFD622F3D138

Note that the key 648ACFD622F3D138 was the first one to be shown in the error message from the previous step.请注意,密钥648ACFD622F3D138是第一个显示在上一步的错误消息中的密钥。 It actually told me there were 3 missing keys, but dealing with the first one was sufficient to now update the package list once again and then being able to install the module finally.它实际上告诉我缺少 3 个键,但处理第一个键就足以现在再次更新包列表,然后最终能够安装模块。

sudo apt update
sudo apt-get install python3-pyside2.qtwebengine

I apparently don't have enough rep to comment.我显然没有足够的代表发表评论。 but editing the sources file above should be sudo nano /etc/apt/sources.list但编辑上面的源文件应该是sudo nano /etc/apt/sources.list

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

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