Reputation: 6093
I setup a virtualenv and installed pyqt5 (PyQt5-5.7-cp35-cp35m-manylinux1_x86_64.whl):
virtualenv -p /usr/bin/python3.5 .
source bin/activate
pip install pyqt5
I created a basic.qml file:
import QtQuick 2.7
import QtQuick.Controls 2.0
Rectangle {
width: 300
height: 100
color: "red"
}
and tried to load it in my python code with:
import sys
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtQuick import QQuickView
if __name__ == '__main__':
myApp = QApplication(sys.argv)
view = QQuickView()
view.setSource(QUrl('basic.qml'))
view.show()
sys.exit(myApp.exec_())
It fails with
file:///[...]/main.qml:2:1: plugin cannot be loaded for module "QtQuick.Controls": Cannot load library /[virtualenv]/lib/python3.5/site-packages/PyQt5/Qt/qml/QtQuick/Controls.2/libqtquickcontrols2plugin.so: (libQt5QuickTemplates2.so.5: Can't open shared object file: File or directory not found)
import QtQuick.Controls 2.0
^
Process finished with exit code 0
I checked. This file it complains about actually doesn't exist. But how can I install it? Does PyQt5 support QtQuickControls2 at all?
If I switch the import in basic.qml from import QtQuick.Controls 2.0
to import QtQuick.Controls 1.2
, it works. But I want to use the new controls.
Upvotes: 1
Views: 2741
Reputation: 5836
This looks like a bug in PyQt5. The package is missing both libQt5QuickTemplates2.so
and libQt5QuickControls2.so
.
Hoping that the Qt 5.7 build contained by the PyQt 5.7 package and the official Qt 5.7 build available at qt.io are built in a fully binary compatible way, one possibility could be to download and install Qt 5.7 from qt.io, and copy the missing libraries into your virtualenv. For example:
$ cp ~/Qt/5.7/gcc_64/lib/libQt5QuickTemplates2.* path/to/lib/python3.5/site-packages/PyQt5/Qt/lib
$ cp ~/Qt/5.7/gcc_64/lib/libQt5QuickControls2.* path/to/lib/python3.5/site-packages/PyQt5/Qt/lib
Upvotes: 1