简体   繁体   中英

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:

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. Same goes for PyQt5 which I could use alternatively, but it does not exist there either.

So my question is: Is there any way to run my Python application, which uses QtWebEngine, on my Raspberry Pi (Raspbian 10 "Buster")? Also I have 6 Pi's which need to run the application. 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). Would that work? Is it okay to work-around the issue despite the fact that QtWebKit is deprecated? 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...

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. 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. 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. Here is how:

Open your sources.list file

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. 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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