Search code examples
python-3.xpyqt5pyinstallerpy2exe

PyQt5 application is not working (just cmd flashing) when built with PyInstaller or py2exe, missing dll's


I've created a script in python that is using PyQt5. Now everything works when I'm launching the file from my editor - Studio Code in this case.

I'm having a problem when I try to deploy an exe using PyInstaller or py2exe it gives me error on missing dll's when it's building. It still finishes building anyway, but when I try to run the exe file the cmd window just flashes for a brief moment and nothing more happens.

I suppose this is due to missing dll's and if not than I have to sort this out first anyway.

I've tried searching for the dll's I'm missing on my computer and some I couldn't find at all e.g. Qt53DInput and one I could find in what I suppose is application made in Qt - Qt5Multimedia .

I'm currently using python 3.7.4 which I've already tried reinstalling. I think I didn't try to reinstall PyQt5, should I try doing that?

from PyQt5 import QtWidgets, uic, QtGui, QtCore, QtQuick
import sys
import os.path
import datetime
import shutil

I guess the only important part of my script in this case are the imports, so I've included them here.

python -m PyInstaller --paths C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyQt5\Qt\bin my_code.py

Somewhere I've read that it's good idea to include this path, but since the dll are not to be found anywhere, including this folder, then obviously didn't help at all.

This is the warning about the dll's I'm getting:

Looking for dynamic libraries
32805 WARNING: lib not found: Qt5MultimediaQuick.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtMultimedia\declarative_multimedia.dll
58554 WARNING: lib not found: Qt53DInput.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
58844 WARNING: lib not found: Qt53DAnimation.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
58989 WARNING: lib not found: Qt53DRender.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
59284 WARNING: lib not found: Qt53DLogic.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
59440 WARNING: lib not found: Qt53DCore.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene3D\qtquickscene3dplugin.dll
60365 WARNING: lib not found: Qt53DQuickScene2D.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene2D\qtquickscene2dplugin.dll
60680 WARNING: lib not found: Qt53DRender.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene2D\qtquickscene2dplugin.dll
60992 WARNING: lib not found: Qt53DCore.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PyQt5\Qt\qml\QtQuick\Scene2D\qtquickscene2dplugin.dll
84256 WARNING: lib not found: api-ms-win-core-winrt-l1-1-0.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyQt5\Qt\bin\qt5bluetooth.dll
84545 WARNING: lib not found: api-ms-win-core-winrt-string-l1-1-0.dll dependency of C:\Users\bonana\AppData\Local\Programs\Python\Python37-32\Lib\site-packages\PyQt5\Qt\bin\qt5bluetooth.dll

Solution

  • Maybe it's not complete answear to why PyInstaller or py2exe is not working, but I've found way to deploy my exe properly. I've used fman build system. It didn't work right off the bat though. I had to install windows 10 sdk and make small change to my code:

        QFileDialog.getOpenFileName(appctxt)
    

    This no longer worked, because for some reason it needed to be changed to:

        QtWidgets.QFileDialog.getOpenFileName(appctxt)
    

    Other than that everything including creation of an installer worked without a problem.