I want to install some third-party Python modules for QGIS 3 on Mac, however, I have no clue how to do it, since I am not so much familiar with different Python environments.

Is there any similar thing to the OSGeo4W Shell on Mac, or is it possible to do via the terminal?

  • I ended up building the packages in another python and copying them into /Applications/QGIS3.14.app/Contents/Resources/python. Nasty. Jun 24 '20 at 9:28

from Download for Macos

These packages use the python.org Python 3, version 3.6, the "macosx10.9" build - other distributions are not supported. Install Python before installing QGIS.

1) To know the python interpreter path used by QGIS

In the Python console of QGIS

import sys

2) then in the terminal

$ /usr/local/bin/python3.6
Python 3.6.8 

3) and you can install third-party Python modules from the terminal

/usr/local/python/bin/python3.6 -m pip install shapely


/usr/local/bin/python3.6 setup.py install


I cannot install the 3.10 version in my Mac, but if I examine the application file:

The content of /Applications/QGIS3.10.app/Contents/MacOS/

The QGIS executable is here

enter image description here

In the /Applications/QGIS3.10.app/Contents/MacOS/bin folder

enter image description here

There is a symbolic link file python3 that points to /Applications/QGIS3.10.app/QGIS3.10.app/Contents/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python

enter image description here

  • Hi and thanks for the answer. When I run the command sys.executable from my python console I get the following link: /Applications/QGIS3.10.app/Contents/MacOS/QGIS, and when I type it in the terminal then QGIS3 just opens. Is there an alternative python command to find the path to the python environment?
    – Pawel
    Feb 20 '20 at 16:00
  • In the Python console of QGIS ? (because /Applications/QGIS3.10.app/Contents/MacOS/QGIS is the executable of QGIS, not of Python) -> see New above
    – gene
    Feb 20 '20 at 17:50
  • It still doesn't work for me when I enter these directories and type python -m pip install 'package'. It's like the python that is being called is the default python installed on Mac and not the python installed in the QGIS3 environment... Is there a terminal command to make sure that the python and pip called is the one running in QGIS3, and not the other one (though the versions are the same)?
    – Pawel
    Feb 21 '20 at 15:45
  • The one running in QGIS3 is the sys.executable result in the QGIS3 Python console (the default python installed on Mac is version 2.x)
    – gene
    Feb 21 '20 at 16:08
  • I remember that I had once changed the main python of the mac from 2 to 3, but how do I call the one in the python console from the terminal?
    – Pawel
    Feb 21 '20 at 18:17

Tested on QGIS 3.14 under MacOSX 10.15.

In QGIS, go to menu Settings > System and search for Environment options:

enter image description here

Check the Use custom variables checkbox, and :

  • In the Apply column, choose Append ;
  • In the Variable column, write PYTHONPATH ;
  • In the Value column, write the path to the directory with python modules as :/Users/me/Library/Python/3.8/lib/python/site-packages

Beware, to correctly separate environment variables, don't forget the colon.

Restart QGIS and in the QGIS Python console, try to import your module.

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.