Home > Software engineering >  python exe error when importing PyQt5 and opening Mixxx
python exe error when importing PyQt5 and opening Mixxx

Time:10-18

I have made a small program for dj automation.

The code:

#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)

if you compile the above script with pyinstaller the run it everything works good (mixxx.exe is opening correctly). But if you uncomment the first import line then when trying to run it this error happens:

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.

The output if I don't use: from PyQt5 import QtCore,QtGui,QtWidgets

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.

It seems that PyQt5 imports are affect pywinauto start or Mixx program which is writter in C qt.

What's wrong and how can i fix it?

The problem exists only after pyinstaller compilation.

Note that if i create an .exe with this code:

from PyQt5 import QtCore, QtGui, QtWidgets

or with an pyuic5 py file created from Qt Designer there is no error.

The error exists only when i import PyQt5 and then try to open mixx (pyinstaller). If i import PyQt5 and then try to open another app like calc there is no problem...

CodePudding user response:

The actual problem was that the platforms plugin of python PyQt5 was interfered with platforms plugin of Qt C (mixxx).

The problem was solved by extending:

Popen(r'C:\Program Files\Mixxx\mixxx.exe')

with this:

Popen(r'C:\Program Files\Mixxx\mixxx.exe', env=dict(os.environ, QT_PLUGIN_PATH=''))

This change stores QT_PLUGIN_PATH the right value ('').

Thanks to @relent95 because he was the solver of the problem.

  • Related