2

I am trying to talk to the PyQGIS API for use in a 3rd party application using the offical .dmg image provided on the QGIS homepage.

After setting PYTHONPATH to /Applications/QGIS3.4.app/Contents/Resources/python and initializing everything as stated in https://docs.qgis.org/3.4/en/docs/pyqgis_developer_cookbook/intro.html#using-pyqgis-in-custom-applications, I am facing the following error when running from PyQt5.QtGui import or from qgis import *:

  ImportError: dlopen(/Applications/QGIS3.4.app/Contents/Resources/python/PyQt5/QtGui.so, 2): Library not loaded: @executable_path/../Frameworks/QtGui.framework/QtGui
  Referenced from: /Applications/QGIS3.4.app/Contents/Resources/python/PyQt5/QtGui.so
  Reason: image not found

Looks like I need to set some linkers or similar?

Side facts:
- I have no problems when using the homebrew version of QGIS).
- I am on macOS 10.14.6 (Mojave)

0

1 Answer 1

1

A solution is to add the QGIS app binaries to the path to replace MacOS Python3 with the embed QGIS Python3, so, as PYTHONPATH :

export PATH="/Applications/QGIS3.4.app/Contents/MacOS/bin:$PATH"

and if necessary, if the Qt platform can't load correctly, following this answer :

export QT_QPA_PLATFORM_PLUGIN_PATH=/Applications/QGIS3.4.app/Contents/PlugIns
export GDAL_DATA=/Applications/QGIS3.4.app/Contents/Resources/gdal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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