2

Currently I am developping a standalone python app and I am now working on the packaging with PyInstaller.

Configuration :

  • OS : Windows 10
  • QGIS : 3.4.9
  • PyInstaller : 3.5

Pyinstaller correctly finds many dependencies and manages to create an executable.

But when I run it, the output is :

  File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "qgis\gui\__init__.py", line 27, in <module>
RuntimeError: qgis._gui cannot import type '����' from PyQt5.QtCore
[6752] Failed to execute script main

I found that the sip folder in QGIS 3.4\apps\Python37\ contains many files that might be useful, so I manually added the content of sip\PyQt5 in the PyInstaller package with other PyQt5 stuff and the new output is :

  File "C:\PROGRA~1\QGIS3~1.4\apps\Python37\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "qgis\gui\__init__.py", line 27, in <module>
RuntimeError: the PyQt5.Qsci module failed to register with the sip module
[4092] Failed to execute script main

Any idea about a file or folder I forgot to package ? For PyInstaller I use a default .spec file.

Reviewing Working Windows Standalone .EXE From QGIS Python Script Using PyInstaller? with QGIS 2 didn't help

1

Found a workaround:

I installed QGIS 3.4 LTR and pyinstaller in a miniconda environment on Windows 10.

(Add conda-forge channel to install QGIS)

I had to add the platforms/ directory in the data section of pyinstaller .spec file (qt platform directory found in the conda environment Library/ folder) for Qt to work.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.