I using Python Interpreter C:\OSGeo4W\apps\Python39\python.exe and QGis 3.22 and IDE Pycharm 2022.2.2
Kind regards / Spozdravom ************************************ Ing. Stanislav Klanduch firm owner KAnet soft-net services Kuzmányho 902 01701 Považská Bystrica Slovakia (SK) tel: +421 6504 07170 mobil: +421 918 394 876 fax: +421 6504 07170 mail: <mailto:off...@kanet.sk> off...@kanet.sk web: <http://www.kanet.sk> www.kanet.sk ************************************ P Pred vytlacením tohto mailu prosím zvážte dopad na životné prostredie. Dakujeme. / Please consider the environment before printing this e-mail. Thanks. From: off...@kanet.sk <off...@kanet.sk> Sent: Monday, March 20, 2023 10:50 AM To: 'qgis-developer@lists.osgeo.org' <qgis-developer@lists.osgeo.org> Subject: Problem with creating EXE aplikation PyQGIS Hallo, I have a larger application, just this small test, I'm trying pyinstaller. I am testing a simple PyQgis application. When I add the line "from qgis.core import QgsApplication" and make an exe via pyinstaller, the application crashes with an error: When I comment out the line "from qgis.core import QgsApplication" the application window starts normally after creating the EXE. See Code: import sys from qgis.PyQt.QtWidgets import QApplication, QMainWindow, QWidget, QHBoxLayout, QLabel from qgis.core import QgsApplication class MainWindow(QMainWindow): def __init__(self, parent=None): super(MainWindow, self).__init__(parent) self.setWindowTitle("Mapová prezeračka --- Pebieha načítanie dát ...") self.init_gui() self.show() def init_gui(self): self.formular = QWidget() layoutFormulara = QHBoxLayout() self.formular.setLayout(layoutFormulara) boxLayout1 = QHBoxLayout() boxLayout2 = QHBoxLayout() layoutFormulara.addStretch() layoutFormulara.addLayout(boxLayout1) layoutFormulara.addLayout(boxLayout2) layoutFormulara.addStretch() self.label1 = QLabel("Hello") boxLayout1.addWidget(self.label1) self.setCentralWidget(self.formular) def main(): # vytvoriť hlavné okno mainWin = MainWindow() mainWin.show() # Run aplikáciu try: retval = app.exec_() # Exit aplication sys.exit(retval) # this will always trigger SystemExit except SystemExit: print("sys.exit() it worked as expected ") except: print("Something has gone terribly wrong ") # another exception was raised if __name__ == "__main__": app = QApplication(sys.argv) main() I looked for many answers on the Internet but I couldn't find anything. I've read the pyinstaller manual, I'm just new to this. I am sending a TestEXE.spec file. Pripájam file spec. import os block_cipher = None workdir = os.getenv('VIEWER_DIR') a = Analysis(['main.py'], pathex=[workdir], binaries=None, datas=[(os.path.join(workdir,'testdata/*'),'testdata'), (os.path.join(workdir,'qgis_plugins/*'),'qgis_plugins'), (os.path.join(workdir,'graphics/*'),'graphics'),], hiddenimports=['qgis.PyQt.QtWidgets','qgis.core.QgsApplication'] hookspath=None, runtime_hooks=None, excludes=None, win_no_prefer_redirects=None, win_private_assemblies=None, cipher=block_cipher) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, [], exclude_binaries=True, name='TestEXE', debug=True, bootloader_ignore_signals=False, strip=False, upx=True, console=False , icon='graphics/airports.ico') coll = COLLECT(exe, a.binaries, a.zipfiles, a.datas, strip=False, upx=True, upx_exclude=[], name='TestEXE') Thank you very much in advance for your help. Kind regards / Spozdravom ************************************ Ing. Stanislav Klanduch firm owner KAnet soft-net services Kuzmányho 902 01701 Považská Bystrica Slovakia (SK) tel: +421 6504 07170 mobil: +421 918 394 876 fax: +421 6504 07170 mail: <mailto:off...@kanet.sk> off...@kanet.sk web: <http://www.kanet.sk> www.kanet.sk ************************************ P Pred vytlacením tohto mailu prosím zvážte dopad na životné prostredie. Dakujeme. / Please consider the environment before printing this e-mail. Thanks.
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer