[Qgis-user] QGIS 4 Mac - Install additional python packages

Ujaval Gandhi ujaval at spatialthoughts.com
Sat Mar 14 02:25:01 PDT 2026


Hi Josh,


Use the snippet below. This was suggested by Matthias Kuhn in this discussion.
https://github.com/qgis/QGIS/issues/63939#issuecomment-3621819919.
[https://github.com/qgis/QGIS/issues/63939#issuecomment-3621819919.] Tested and
works fine on QGIS 4.0.0 on Mac


import subprocess
import sys
from pathlib import Path

# Get the root directory with our applications
python_dir = Path(sys.executable).parent

python_executable = python_dir / "python"

def install(package):
    subprocess.check_call([str(python_executable), "-m", "pip", "install",
package])

install("yourpackage")


---
Ujaval Gandhi
Spatial Thoughts
www.spatialthoughts.com [http://www.spatialthoughts.com]




On Fri, Mar 13, 2026 at 5:52 AM Josh Mawer via QGIS-User
<qgis-user at lists.osgeo.org> wrote:

> Hi QGIS User List,
> 
> 
> I am developing a python based QGIS processing script which is working great
> on a Windows installation.  However, when I try to run it on my Mac I get an
> error stating the Matplotlib package is not installed in the python
> environment.
> 
> 
> How can I install additional packages into the QGIS python environment?  I
> have found a few old StackOverflow threads mentioning installing via Pip3 from
> within the QGIS Application Package.  However, Pip3 doesn't seem to be
> contained there any more.
> 
> 
> Any thoughts? Thanks,
> _______________________________________________
> QGIS-User mailing list
> QGIS-User at lists.osgeo.org [QGIS-User at lists.osgeo.org]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
> [https://lists.osgeo.org/mailman/listinfo/qgis-user]
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> [https://lists.osgeo.org/mailman/listinfo/qgis-user]

[data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACwAAAAAAQABAAACAkQBADs=3D]
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260314/7038febd/attachment.htm>


More information about the QGIS-User mailing list