首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >导入PyQt5并打开Mixxx时发生python错误

导入PyQt5并打开Mixxx时发生python错误
EN

Stack Overflow用户
提问于 2022-10-15 02:22:13
回答 1查看 62关注 0票数 0

我为dj自动化做了一个小程序。

守则:

代码语言:javascript
复制
#from PyQt5 import QtCore, QtGui, QtWidgets
from pywinauto.application import Application as PyWinAutoApplication
from subprocess import Popen
import time
import os

os.environ["QT_DEBUG_PLUGINS"] = "1"

#Open mixxx
Popen(r'C:\Program Files\Mixxx\mixxx.exe')
#time.sleep(5)
#mixxx_app = PyWinAutoApplication(backend="uia").connect(title="Mixxx")
while(True):
    time.sleep(10)

如果您用pyinstaller编译上面的脚本,运行它,一切正常(mixxx.exe打开正确)。但是,如果取消对第一个导入行的注释,那么在尝试运行它时会发生以下错误:

代码语言:javascript
复制
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qminimal.dll"
Found metadata in lib C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qminimal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qoffscreen.dll"
Found metadata in lib C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qoffscreen.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qwebgl.dll"
Found metadata in lib C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qwebgl.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "webgl"
        ]
    },
    "archreq": 0,
    "className": "QWebGLIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Program Files/Mixxx/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Program Files/Mixxx/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/platforms" ...
Cannot load library C:\Users\cpapp\OneDrive\???????????\dist\py_error_1\PyQt5\Qt5\plugins\platforms\qwindows.dll: The specified procedure could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Users/cpapp/OneDrive/???????????/dist/py_error_1/PyQt5/Qt5/plugins/platforms/qwindows.dll" : "Cannot load library C:\\Users\\cpapp\\OneDrive\\???????????\\dist\\py_error_1\\PyQt5\\Qt5\\plugins\\platforms\\qwindows.dll: The specified procedure could not be found."
qt.qpa.plugin: Could not load the Qt platform plugin "windows" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: minimal, offscreen, webgl, windows.

如果我不使用的输出:from PyQt5 import QtCore,QtGui,QtWidgets

代码语言:javascript
复制
C:\Users\cpapp\OneDrive\Υπολογιστής\dist\py_error_1>py_error_1.exe
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Program Files/Mixxx/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Program Files/Mixxx/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/platforms" ...
loaded library "C:/Program Files/Mixxx/plugins/platforms/qwindows.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/plugins/styles" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Program Files/Mixxx/plugins/styles/qwindowsvistastyle.dll"
Found metadata in lib C:/Program Files/Mixxx/plugins/styles/qwindowsvistastyle.dll, metadata=
{
    "IID": "org.qt-project.Qt.QStyleFactoryInterface",
    "MetaData": {
        "Keys": [
            "windowsvista"
        ]
    },
    "archreq": 0,
    "className": "QWindowsVistaStylePlugin",
    "debug": false,
    "version": 331520
}


Got keys from plugin meta data ("windowsvista")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Program Files/Mixxx/styles" ...
loaded library "C:/Program Files/Mixxx/plugins/styles/qwindowsvistastyle.dll"
Warning [Main]: Failed to load "mixxx" translations for locale "el_GR" from "C:/Program Files/Mixxx/translations/"
Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/iconengines/qsvgicon.dll, metadata=
{
    "IID": "org.qt-project.Qt.QIconEngineFactoryInterface",
    "MetaData": {
        "Keys": [
            "svg",
            "svgz",
            "svg.gz"
        ]
    },
    "archreq": 0,
    "className": "QSvgIconPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qgif.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "gif"
        ],
        "MimeTypes": [
            "image/gif"
        ]
    },
    "archreq": 0,
    "className": "QGifPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qicns.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "icns"
        ],
        "MimeTypes": [
            "image/x-icns"
        ]
    },
    "archreq": 0,
    "className": "QICNSPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qico.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "ico",
            "cur"
        ],
        "MimeTypes": [
            "image/vnd.microsoft.icon",
            "image/vnd.microsoft.icon"
        ]
    },
    "archreq": 0,
    "className": "QICOPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qjp2.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "jp2"
        ],
        "MimeTypes": [
            "image/jp2",
            "image/jpx",
            "image/jpm",
            "video/mj2"
        ]
    },
    "archreq": 0,
    "className": "QJp2Plugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qjpeg.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "jpg",
            "jpeg"
        ],
        "MimeTypes": [
            "image/jpeg",
            "image/jpeg"
        ]
    },
    "archreq": 0,
    "className": "QJpegPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qsvg.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "svg",
            "svgz"
        ],
        "MimeTypes": [
            "image/svg+xml",
            "image/svg+xml-compressed"
        ]
    },
    "archreq": 0,
    "className": "QSvgPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qtga.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "tga"
        ],
        "MimeTypes": [
            "image/x-tga"
        ]
    },
    "archreq": 0,
    "className": "QTgaPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qtiff.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "tiff",
            "tif"
        ],
        "MimeTypes": [
            "image/tiff",
            "image/tiff"
        ]
    },
    "archreq": 0,
    "className": "QTiffPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qwbmp.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "wbmp"
        ],
        "MimeTypes": [
            "image/vnd.wap.wbmp"
        ]
    },
    "archreq": 0,
    "className": "QWbmpPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/imageformats/qwebp.dll, metadata=
{
    "IID": "org.qt-project.Qt.QImageIOHandlerFactoryInterface",
    "MetaData": {
        "Keys": [
            "webp"
        ],
        "MimeTypes": [
            "image/webp"
        ]
    },
    "archreq": 0,
    "className": "QWebpPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/sqldrivers/qsqlite.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QSQLITE"
        ]
    },
    "archreq": 0,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QODBC3",
            "QODBC"
        ]
    },
    "archreq": 0,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 331520
}


Warning [Main]: Found metadata in lib C:/Program Files/Mixxx/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QPSQL7",
            "QPSQL"
        ]
    },
    "archreq": 0,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 331520
}


Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.
Warning [Controller]: USB permissions problem (or device error.) Your account needs write access to USB HID controllers.

PyQt5导入似乎会影响C++ qt中的写程序pywinauto或Mixx程序。

有什么问题,我该怎么解决呢?

这个问题只存在于pyinstaller编译之后。

请注意,如果我使用以下代码创建一个.exe:

代码语言:javascript
复制
from PyQt5 import QtCore, QtGui, QtWidgets

或者使用Qt设计器创建的pyuic5 py文件没有错误。

只有当我导入PyQt5,然后尝试打开mixx (pyinstaller)时,才会出现错误。如果我导入PyQt5,然后尝试打开另一个像calc这样的应用程序,那么没有问题.

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-10-17 21:46:25

实际问题是Qt C++平台插件(mixxx)受到PyInstaller对PyQt5初始化的干扰。

解决问题的办法是:

代码语言:javascript
复制
Popen(r'C:\Program Files\Mixxx\mixxx.exe')

在这方面:

代码语言:javascript
复制
Popen(r'C:\Program Files\Mixxx\mixxx.exe', env=dict(os.environ, QT_PLUGIN_PATH=''))

此更改存储QT_PLUGIN_PATH的正确值('')。

因为他是这个问题的解决者。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74076256

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档