1

I'm using the Python Console within QGIS 2.14.3 (MacOS). When I import matplotlib, it imports version 1.4.3 from '/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/init.pyc'. I would like to update matplotlib to a newer version. How do I go about doing that so that QGIS will see it?

A related question: I have miniconda installed in a different location with matplotlib version 2.1.1. When I start python from a MacOS command line, import matplotlib imports from '.../miniconda2/lib/python2.7/site-packages/matplotlib/init.pyc'. Can I point QGIS to my miniconda install or would that be a bad idea?

I am trying to better understand how QGIS and python play together.

1

As already been mentioned many times in GS exchange, the Kyng Chaos QGIS version uses the standard Apple Python version 2.x (and not others Python implementation, Homebrew, Anaconda, etc.)

The Kyng Chaos installer of the Python module Matplotlib installs it into the /Library/Python/2.7/site-packages/matplotlib-override folder with a /Library/Python/2.7/site-packages/matplotlib-override.pth pth files that points to the precedent folder (same for his numpy, numpy-override.pth and scipy, scipy-override.pth installers)

enter image description here

As these name implies, these override all other matplotlib,numpy or scipy folders installations.

You absolutely need the KyngChaos matplotlib installation to install QGIS: It checks to see if the folder exists in the Distribution file of Install QGIS.pkg)

enter image description here

if(!(system.files.fileExistsAtPath('/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/__init__.py') == true)) {
    my.result.title = 'matplotlib';
    my.result.message = 'QGIS requires the Matplotlib python module (kyngchaos build).';
    my.result.type = 'Fatal';
    return false;

When Qgis is installed, nothing prevents you from installing new versions of the modules with pip (sudo -H pip install matplotlib).

You need to delete or rename the matplotlib-override.pth file or replace the content of the matplotlib-override folder with the new matplotlib folder.

But be careful because some libraries located in the QGIS application (/Applications/QGIS.app/Contents/Resources/python, /Applications/QGIS.app/Contents/MacOS/grass/etc/python) needs a specific version of the modules (especially numpy).

| improve this answer | |

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.