Solved PyQt5 QtQuick
-
Hi,
After installing PyQt5.5.1 together with Qt5.5.1 on my Ubuntu 14.04 successfully, I ran my simple pyqt file using QtQuick and met this error:
libQt5Network.so.5: undefined symbol: _Z24qt_subtract_from_timeoutii
Anyone has run into this before?
Thanks.
#!/usr/bin/env python3 import sys from PyQt5.QtCore import QUrl from PyQt5.QtWidgets import QApplication from PyQt5.QtQuick import QQuickView # Main Function if __name__ == '__main__': # Create main app myApp = QApplication(sys.argv) # Create a label and set its properties appLabel = QQuickView() appLabel.setSource(QUrl('basic.qml')) # Show the Label appLabel.show() # Execute the Application and Exit myApp.exec_() sys.exit()
basic.qml:
import QtQuick 2.3 Rectangle { width: 300; height: 300 color: "red" Text { id: helloText anchors.verticalCenter: parent.verticalCenter anchors.horizontalCenter: parent.horizontalCenter text: "Hello World!!!\n Traditional first app using PyQt5" color: "blue" font.family: "Helvetica" font.pointSize: 14 horizontalAlignment: Text.AlignHCenter } Grid { id: colorPicker rows: 2; columns: 3; spacing: 3 Rectangle { color: "white";} Rectangle { color: "green";} Rectangle { color: "blue"; } Rectangle { color: "yellow";} Rectangle { color: "steelblue";} Rectangle { color: "black";} } }
-
The reason is i also installed python-Qt5, which is based on older Qt5 version.
Withfind / -name libQt*
I could see some old qt lib residing in /usr/lib folder:
/usr/lib/i386-linux-gnu/libQt5Network.so
/usr/lib/i386-linux-gnu/libQt5Network.so.5
/usr/lib/i386-linux-gnu/libQt5Network.so.5.2
/usr/lib/i386-linux-gnu/libQt5Network.so.5.2.1/home/tad/Qt5.5.1/gcc/lib/libQt5Network.so.5.5
/home/tad/Qt5.5.1/gcc/lib/libQt5Network.so
/home/tad/Qt5.5.1/gcc/lib/libQt5Network.so.5.5.1
/home/tad/Qt5.5.1/gcc/lib/libQt5Network.so.5/home/tad/Qt5.5.1/Tools/QtCreator/lib/qtcreator/libQt5Network.so.5
/home/tad/Qt5.5.1/Tools/QtCreator/lib/qtcreator/libQt5Network.so.5.5.1
/home/tad/Qt5.5.1/Tools/QtCreator/lib/qtcreator/libQt5Network.so.5The problem maybe inconsistent qt libs, so I remove all qt libs in /usr/lib and replace them with the ones in my home folder. It worked! However this is not recommended since some built-in Ubuntu components may use libQt* in /usr/lib folders. So, just remove python-qt5 and reinstall pyqt5 all over again!
By the way, for the error relating to Sip API version, we just have to run to remove all sip-related packages then reinstall sip again:
dpkg -l | grep sip
then
sudo apt-get purge python3-sip python3-sip-dev