michi.wtr
Goto Top

Pyinstaller: Module PyQt5 not found

Hey guys,

I have a problem to install my python script as an executable.
The script starts a subprocess with pythonw.exe, which executes another script. In the second script I use some imports, why I make some hidden imports using pyinstaller for my executable.

It looks something like this...

script1.py (which is installed as executable):
import sys

# ... bla bla bla, some code here ...

self.__topic[topic] = Popen(
            [
                "assets/executables/pythonw.exe",  
                resourcePath("assets/modules/script2.py"), # calculating the path of the resource from a relative path  
                file,
                encoding,
            ]
            + sys.path
        )

script2.py (which is started and uses some imports, which should be included in the executable):
import sys

if len(sys.argv) > 3:
    sys.path = sys.argv[3:]  # when passing the sys.path I want the modules from the script1.py

from PyQt5.QtCore import Qt, QTimer, QUrl
from PyQt5.QtWebEngineWidgets import QWebEngineView
from PyQt5.QtWidgets import QApplication, QMainWindow, QVBoxLayout, QWidget

script1.spec (just the 'a = Analysis'-part):
a = Analysis(
    ['alert_client.py'],  
    pathex=[],
    binaries=[('.\\\\assets\\\\executables\\\\pythonw.exe', 'assets/executables')],  
    datas=[ ('.\\\\assets\\\\modules\\\\alert.py', 'assets/modules'),  
            ('.\\\\assets\\\\modules\\\\HTMLViewer.py', 'assets/modules'),  
            ('.\\\\assets\\\\pictures\\\\bee-do.gif', 'assets/pictures'),  
            ('.\\\\assets\\\\pictures\\\\firealarm.gif', 'assets/pictures'),  
            ('.\\\\assets\\\\pictures\\\\warning.png', 'assets/pictures'),  
            ('.\\\\assets\\\\sites\\\\fire.css', 'assets/sites'),  
            ('.\\\\assets\\\\sites\\\\fire.html', 'assets/sites'),  
            ('.\\\\assets\\\\sounds\\\\alarm.wav', 'assets/sounds') ],  
    hiddenimports=[ 'PyQt5.QtCore',  
                    'PyQt5.QtWebEngineWidgets',  
                    'PyQt5.QtWidgets' ],  
    hookspath=[],
    hooksconfig={},
    runtime_hooks=[],
    excludes=[],
    noarchive=False,
    optimize=0,
)

My command (to create executable):
pyinstaller .\script1.spec

... bla bla bla, some Info here ...
9668 INFO: Analyzing hidden import 'PyQt5.QtCore'  
9673 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
9862 INFO: Analyzing hidden import 'PyQt5.QtWebEngineWidgets'  
9863 INFO: Analyzing hidden import 'PyQt5.QtWidgets'  
9864 INFO: Processing module hooks...
9868 WARNING: Hidden import "importlib_resources.trees" not found!  
9893 WARNING: Hidden import "pkg_resources._vendor.jaraco.functools" not found!  
9894 WARNING: Hidden import "pkg_resources._vendor.jaraco.context" not found!  
9894 WARNING: Hidden import "pkg_resources._vendor.jaraco.text" not found!  
9894 WARNING: Hidden import "pkg_resources.extern" not found!  
9896 WARNING: Hidden import "sip" not found!  
9896 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
10114 INFO: Loading module hook 'hook-PyQt5.QtWebEngineWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
10474 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
10732 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
11447 INFO: Loading module hook 'hook-PyQt5.QtNetwork.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
11795 INFO: Loading module hook 'hook-PyQt5.QtPrintSupport.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
11971 INFO: Loading module hook 'hook-PyQt5.QtQuick.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
12167 INFO: Loading module hook 'hook-PyQt5.QtQuickWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
12307 INFO: Loading module hook 'hook-PyQt5.QtWebEngineCore.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
12546 INFO: Loading module hook 'hook-PyQt5.QtPositioning.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
12750 INFO: Loading module hook 'hook-PyQt5.QtQml.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
15017 INFO: Loading module hook 'hook-PyQt5.QtWebChannel.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
15181 INFO: Performing binary vs. data reclassification (1524 entries)

What excactly is my problem? Does the sys.path not include the hidden imports? I also tried to make the imports in the script1.py, but because they are not used, it makes no difference...

Help face-sad

Best regards,
Micha


PS: Install script2.py as executable works perfectly fine.... I have no clue what to do:
5783 INFO: Loading module hook 'hook-PyQt5.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
5919 INFO: Loading module hook 'hook-PyQt5.QtCore.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
6117 INFO: Loading module hook 'hook-PyQt5.QtWebEngineWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
6253 INFO: Loading module hook 'hook-PyQt5.QtWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
6425 INFO: Processing module hooks...
6429 WARNING: Hidden import "sip" not found!  
6465 INFO: Loading module hook 'hook-PyQt5.QtGui.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
6866 INFO: Loading module hook 'hook-PyQt5.QtNetwork.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7139 INFO: Loading module hook 'hook-PyQt5.QtPrintSupport.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7316 INFO: Loading module hook 'hook-PyQt5.QtQuick.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7483 INFO: Loading module hook 'hook-PyQt5.QtQuickWidgets.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7592 INFO: Loading module hook 'hook-PyQt5.QtWebEngineCore.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7795 INFO: Loading module hook 'hook-PyQt5.QtPositioning.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
7941 INFO: Loading module hook 'hook-PyQt5.QtQml.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
9062 INFO: Loading module hook 'hook-PyQt5.QtWebChannel.py' from 'C:\\Users\\UserName\\Projects\\alert\\venv\\Lib\\site-packages\\PyInstaller\\hooks'...  
9181 INFO: Performing binary vs. data reclassification (1497 entries)

Why does it work compiling script2.py directly? Can I tell python to import unused imports too?

Content-ID: 73613864590

Url: https://administrator.de/en/pyinstaller-module-pyqt5-not-found-73613864590.html

Ausgedruckt am: 22.12.2024 um 11:12 Uhr