qgis / QGIS

QGIS is a free, open source, cross platform (lin/win/mac) geographical information system (GIS)
https://qgis.org
GNU General Public License v2.0
10.61k stars 3.01k forks source link

Standalone pyqgis application package development failure due to qgis.core dependency on PyQt5 libraries #29159

Closed qgib closed 4 years ago

qgib commented 5 years ago

Author Name: Tong Zhai (Tong Zhai) Original Redmine Issue: 21341 Affected QGIS version: 3.4.4 Redmine category:build/install


We have built standalone pyqgis application in QGIS 2.x with Python 2.7, it worked and also we could package the application with standard package setting using PyInstaller. However, ever since we migrated to QGIS 3.x with Python 3, PyInstaller package building has been unsuccessful. The latest LTR QGIS 3.4.4 failed to support pyinstaller packaging also.

Below are the details: We installed the QGIS software using OSGEO4W installer (osgeo4w-setup-x86_64.exe) on a windows 7 desktop Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32 PYQT_VERSION_STR: 5.11.3 Qgis.QGIS_VERSION: '3.4.4-Madeira'

Attached files: The test standalone qgis application runs in the PyCharm develop environment, this file is attached (qgis_test_issue.py) PyInstaller (version 3.4) spec file for the test python file is also attached (qgis_test_issue.spec)

The packaging process can run to completion, but when running the packaged 'qgis_test_issue.exe', it always complains about missing Qt5 libraries upon qgis.core import:

Traceback (most recent call last):
  File "qgis_test_issue.py", line 6, in <module>
    from qgis.core import QgsApplication, QgsVectorLayer, QgsProject
  File "c:\OSGEO4~1\apps\Python37\lib\site-packages\pyinstaller-3.4-py3.7.egg\PyInstaller\loader\pyimod03_importers.py", line 627, in exec_module
    exec(bytecode, module.__dict__)
  File "qgis\core\__init__.py", line 27, in <module>
ModuleNotFoundError: No module named 'PyQt5.QtPrintSupport'
[6792] Failed to execute script qgis_test_issue

I also ran a script to get the following library path settings from the version 3.4.4 OSGeo4W installation:

{'isDebugBuild': False,
 'location': {'ArchDataPath': 'C:/OSGEO4~1/apps/Qt5',
              'BinariesPath': 'C:/OSGEO4~1/apps/Qt5/bin',
              'DataPath': 'C:/OSGEO4~1/apps/Qt5',
              'DocumentationPath': 'C:/OSGEO4~1/apps/Qt5/doc',
              'ExamplesPath': 'C:/OSGEO4~1/apps/Qt5/examples',
              'HeadersPath': 'C:/OSGEO4~1/apps/Qt5/include',
              'ImportsPath': 'C:/OSGEO4~1/apps/Qt5/imports',
              'LibrariesPath': 'C:/OSGEO4~1/apps/Qt5/lib',
              'LibraryExecutablesPath': 'C:/OSGEO4~1/apps/Qt5/bin',
              'PluginsPath': 'C:/OSGEO4~1/apps/Qt5/plugins',
              'PrefixPath': 'C:/OSGEO4~1/apps/Qt5',
              'Qml2ImportsPath': 'C:/OSGEO4~1/apps/Qt5/qml',
              'SettingsPath': '',
              'TestsPath': 'C:/OSGEO4~1/apps/Qt5/tests',
              'TranslationsPath': 'C:/OSGEO4~1/apps/Qt5/translations'},
 'version': [5, 11, 2]}


Related issue(s): #29158 (copied_to) Redmine related issue(s): 21340


qgib commented 5 years ago

Author Name: Tong Zhai (Tong Zhai)


alexbruy commented 4 years ago

I'm afraid this is not a QGIS issue. You need to adjust PyInstaller configuration and include all missed libraries.