Issue
I have my first qt quick 2 pyside application,my app don't run and show below error
main.py file
import sys,os
from PySide6.QtGui import QGuiApplication
from PySide6.QtQml import QQmlApplicationEngine
import PySide6
if __name__ == "__main__":
#==== [ spcify where is plugins of windows ] ===
dirname=os.path.dirname(PySide6.__file__)
plugin_path = os.path.join(dirname, 'plugins', 'platforms')
os.environ['QT_QPA_PLATFORM_PLUGIN_PATH'] = plugin_path
#==================================================
app = QGuiApplication(sys.argv)
engine = QQmlApplicationEngine()
engine.load(os.path.join(os.path.dirname(__file__), "main.qml"))
if not engine.rootObjects():
sys.exit(-1)
sys.exit(app.exec_())
main.pyproject file
{
"files": ["main.qml","main.py"]
}
I am using C:\Users\MyUserName\anaconda3\python.exe
for compiling
Application output
13:34:50: Starting C:\Users\MyUserName\anaconda3\python.exe -u D:\QtProjects\qtforpythonprojects\MyFirstApp\main.py...
Found invalid metadata in lib C:/Users/MyUserName/anaconda3/Library/plugins/platforms/qdirect2d.dll: Invalid metadata version
Found invalid metadata in lib C:/Users/MyUserName/anaconda3/Library/plugins/platforms/qminimal.dll: Invalid metadata version
Found invalid metadata in lib C:/Users/MyUserName/anaconda3/Library/plugins/platforms/qoffscreen.dll: Invalid metadata version
Found invalid metadata in lib C:/Users/MyUserName/anaconda3/Library/plugins/platforms/qwindows.dll: Invalid metadata version
Found invalid metadata in lib C:/Users/MyUserName/anaconda3/Library/qml/QtQuick.2/qtquick2plugin.dll: Invalid metadata version
QQmlApplicationEngine failed to load component
file:///D:/QtProjects/qtforpythonprojects/MyFirstApp/main.qml:1:1: Failed to extract plugin meta data from 'C:/Users/MyUserName/anaconda3/Library/qml/QtQuick.2/qtquick2plugin.dll'
13:34:52: C:\Users\MyUserName\anaconda3\python.exe exited with code -1
Solution
I was using Python 3.8 and based on qt docs this version was missing some Api so I installed last version of python(3.9) and now the problem is solved :>
Note
Python 3.8.0 was missing some API required for PySide/Shiboken so it’s not possible to use it for a Windows build.
Answered By - mohsen
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.