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

Josh Mawer jmawer at fastmail.com
Sat Mar 14 18:01:23 PDT 2026


Unfortunatley that doesn’t work for me either.

It fails with the following error:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "Untitled-0", line 13, in <module>
  File "Untitled-0", line 11, in install
  File "/Applications/QGIS 4.app/Contents/Frameworks/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/Applications/QGIS 4.app/Contents/MacOS/python', '-m', 'pip', 'install', 'matplotlib']' returned non-zero exit status 126.



On Sat, 14 Mar 2026, at 10:25 PM, Ujaval Gandhi wrote:
> Hi Josh,
> 
> Use the snippet below. This was suggested by Matthias Kuhn in this discussion. 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
> 
> 
> 
> 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
>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-user
>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-user
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260315/77b4e227/attachment.htm>


More information about the QGIS-User mailing list