本文介绍了无法从 pyside 应用程序中的 qtquick2plugin.dll 中提取插件元数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的第一个 qt quick 2 pyside 应用程序,我的应用程序无法运行并显示以下错误

I have my first qt quick 2 pyside application,my app don't run and show below error

ma​​in.py 文件

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_())

ma​​in.pyproject 文件

{
    "files": ["main.qml","main.py"]
}

我正在使用 C:\Users\MyUserName\anaconda3\python.exe 进行编译

I am using C:\Users\MyUserName\anaconda3\python.exe for compiling

应用输出

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

推荐答案

我使用的是 Python 3.8 并基于 qt docs 这个版本缺少一些 Api,所以我安装了最新版本的 python(3.9),现在问题解决了:>

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

注意

Python 3.8.0 缺少 PySide/Shiboken 所需的一些 API,因此无法将其用于 Windows 构建.

Python 3.8.0 was missing some API required for PySide/Shiboken so it’s not possible to use it for a Windows build.

这篇关于无法从 pyside 应用程序中的 qtquick2plugin.dll 中提取插件元数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-03 23:50