3

I'm trying to import the qgis.core module as explained here: https://docs.qgis.org/testing/en/docs/pyqgis_developer_cookbook/intro.html

I'm working on a macOS system and installed python.org Python 3.6. Then I installed qgis.org QGIS 3 and did the following steps:

  • Check QGIS install path:

QgsApplication.prefixPath() '/Applications/QGIS3.app/Contents/MacOS'

  • Change PYTHONPATH, PATH, LD_LIBRARY_PATH to:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/Applications/QGIS.app/Contents/MacOS/lib/:/Applications/QGIS.app/Contents/Frameworks/

export PYTHONPATH=$PYTHONPATH:/Applications/QGIS.app/Contents/Resources/python/

export PATH=$PATH:/Library/Frameworks/GDAL.framework/Programs/

  • Write this code into Python IDLE:

from qgis.core import *

  • Then I get this error message:

Traceback (most recent call last): File "<pyshell#1>", line 1, in <module> from qgis.core import * ModuleNotFoundError: No module named 'qgis'

Could anyone help me?

  • 2
    You can't use Anaconda python with QGIS 3 on MacOS, The KyngChaos packages specifically state they are only compatible with Python.org python, not Anaconda/Homebrew/MacPorts/etc... kyngchaos.com/blog/2018/… – user2856 Jun 1 '18 at 12:20
  • Okay thx. Is it then possible to install now python.org python 3.6 while keeping anaconda python 3.6 on macOS? – user121692 Jun 1 '18 at 12:29
  • Yes, they shouldn't interfere, just watch out for this issue. – user2856 Jun 1 '18 at 12:49

Your Answer

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

Browse other questions tagged or ask your own question.