1

I am stuck with one error while building PyQt5 for rasberry pi. I was successfully able to run the application which uses QQmlApplicationEngine on Windows Desktop. Now I wanted to run the same application in Raspberry pi 3. I build the PyQt5 (5.4.1v) from the source and tried running the application but I get error:

ImportError: No Module Found "PyQt5.QtQml".

I realized that, when I build the PyQt5 from the source, I get:

Project Error: Unknown module(s) in QT: qml

and shows me a list of modules which will be built.

Just for a reference, I am using a raspbian, and have installed the following before building PyQt5.

sudo apt-get update

sudo apt-get install qtcreator

sudo apt-get install qt5-qmake

added "export QT_SELECT = qt5" to my "~/.profile" and "~/.bashrc"

sudo apt-get install qt5-default qt5-qmake qtbase5-dev-tools qttools5-dev-tools build-essential libboost-dev libboost-system-dev libboost-filesystem-dev libboost-program-options-dev libboost-thread-dev libssl-dev libdb++-dev libgl1-mesa-dev

How am I supposed to install QtQml in PyQt5? Please help...

Thanks in Advance.

Community
  • 1
  • 1
ryuk
  • 47
  • 2
  • 7

1 Answers1

3

PyQt5 is (as you perhaps know) just a wrapper for the Qt C++ libraries. In order to use a specific module in PyQt5 the underlying C++ library needs to be installed.

The first error message shows that PyQt5.QtQml module is missing which respectively leads to the conclusion that the underlying Python wrapper is missing.

The second error message is probably generated on the C++ level and means that the required Qt C++ library for this module is missing.

Since you are building PyQt5 you not only need the runtime libraries but also the development packages for Qt. For QML you need the qtdeclerative5-dev package and the libqt5qml5 (I think that was the name for the runtime library). These of course depend on a bunch of other packages which will automatically be installed.

PS: Don't forget the SIP library which PyQt has as a dependency no matter which Qt modules you want to use.

rbaleksandar
  • 8,713
  • 7
  • 76
  • 161
  • Yoo. Thanks... I was missing qtdeclarative5-dev and libqt5qml5. After installing, it was set work, it worked when I imported PyQt5.QtQml on python console. Just another question, where can I find the list of dependencies required to install certain packages of PyQt5, since I am not sure when will I require another packages and will be absent. Don't want to bug anyone because of this again. – ryuk Feb 05 '17 at 04:51
  • You can look at the [list of all components](http://pyqt.sourceforge.net/Docs/PyQt5/py-modindex.html) supported by PyQt5 and from there you have to look at the [official Qt docs](http://doc.qt.io) or Google to look for clues. Dependencies (package-wise) can be retrieved by using `apt-cache depends ` or looking at the `Dependecies` tap inside the Synaptic package manager when a given package is selected. Usually you don't need to do that if you install things through the repos but since you are building it yourself I guess that's the way to go. :) Hope this helps. – rbaleksandar Feb 05 '17 at 10:11
  • I was trying to go with the easy way, but I didn't find the PyQt 5.7.1 or greater version when I downloaded with sudo apt-get install. So, I had to compile it from the source. Now I am getting an error module ` "QtQuick" version 2.7` is not installed and I am able to download `version 1.0` which doesnot fullfill my purpose. Same is with `QtQuckControls 2.0` which I need, but has `version 1.0` – ryuk Feb 06 '17 at 18:38
  • I would suggest building both the lastest Qt5 with the latest compatible PyQt5 from source. Qt tends to change a lot especially when it comes to QML. There are multiple versions of most QML components and it's a nightmare to deal with all that. That is why I use it only if I'm forced to (for example: project at work). You have `QtQml`, `QtQuick`, `QtQuickControls` and `QtQuickControls2` (you can see all the gory details [here](https://github.com/qt/)) which just shows how much turbulence there currently is when it comes to this part of the Qt framework. – rbaleksandar Feb 06 '17 at 20:04