I am facing problems in python after installing QGIS. While installing QGIS, it mentioned that it would override my matplotlib and numpy python libraries. I am facing trouble with executing python programs through these overrided libraries. I have tried to uninstall these python libraries using sudo pip uninstall. But it says operation not permitted. Maybe QGIS has modified the sudo settings for these 2 libraries because I am able to add/delete any other python library. I am okay to uninstall QGIS. Can any one share any ideas whats going wrong and how can I restore my numpy and matplotlib libraries to the original versions by python from the versions overrided by QGIS?

  • I thought qgis installed it's own Python version with dependencies? Have they definitely been overridden in your main Python install
    – Liam G
    Jul 17, 2016 at 22:22
  • So I have in my Library/Python/2.7/site-packages matplotlib-override, matplotlib-override.pth, numpy-override, numpy-override.pth which are different from the ones python installs generally as they would be called matplotlib and numpy respectively. Also my System/Library/Frameworks/Python.framework/Version/2.7/Extras/lib/python has matplotlib, matplotlib-1.3.1-py2.7.egg-info and numpy folders.
    – tg89
    Jul 18, 2016 at 0:06

1 Answer 1


It is a general Python question and not a GIS question

1) First of all (for Freight_Train) , Mac OS X is an Unix system with various versions of Python preinstalled and QGIS uses one of them (Python command in /usr/bin/).

$ which python

For Python 2.7, the site-package folder is /Library/Python/2.7/site-packages

2) Then you need to understand what are pth files. The simplest explanation is that of Bob Ipolito (in 2005): Using .pth files for Python development and in the site.py file of your Python installation (/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site.py in Mac OS X for example)

A path configuration file is a file whose name has the form .pth; its contents are additional directories (one per line) to be added to sys.path. Non-existing directories (or non-directories) are never added to sys.path; no directory is added to sys.path more than once. Blank lines and lines beginning with '#' are skipped. Lines starting with 'import' are executed.


The most convenient way is to add a path configuration file to a directory that’s already on Python’s path, usually to the .../site-packages/ directory. Path configuration files have an extension of .pth, and each line must contain a single path that will be appended to sys.path. (Because the new paths are appended to sys.path, modules in the added directories will not override standard modules. This means you can’t use this mechanism for installing fixed versions of standard modules. (Modifying Python’s Search Path)

What does that really mean ?

a) The content of the matplotlib-override.pth file is:

import sys; sys.path.insert(0,'/Library/Python/2.7/site-packages/matplotlib-override')

It tells Python what version of Matplotlib it must use. If you want to use another version of Matplotlib, simply delete this pth file and install a new version of Matplotlib.

With the pth file

import matplotlib 

Without the pth file and with matplotlib installed with pip

import matplotlib

matplotlib-override.pth allows you to choose the matplotlib version

b) But be careful because in Mac OS X GRASS GIS and QGIS are compiled with the override version of Numpy (they therefore expect to find Numpy in numpy-override)

import numpy

Here numpy-override.pth allows the developers to choose the numpy version

4) The problem of osgeo/OGR/GDAL is different because it is not in /Library/Python/2.7/site-packages

import osgeo

gdal-py2.7.pth allows to use the module as if it were in the site-package folder

I hope that you will understand the interest of these pth files used by many Python modules as easy_install.pth used by Pip and easy_install

Thus you don't need to "reset" the Python modules, but only choose the version to use.

  • Thanks a lot Just wanted to know, are the versions of matplotlib and numpy which QGIS overrides, similar to the regular version? Can I use these overrided versions in my python programs just as I would use a regular installation of matplotlib/numpy...are these similar in the basic functionality that numpy and matplotlib provides? Also you mentioned that I could just delete the pth file and reinstall Matplotlib. But there are folders of matplotlib inside matplotlib-override.do these have to be deleted as well? And what differences should I account for applying this procedure to numpy-override?
    – tg89
    Jul 20, 2016 at 7:49
  • You don't understand the principles of the Python Path and the pth file. I have 3 versions of MatplotLib installed and I can choose the one I want in the shell
    – gene
    Jul 20, 2016 at 16:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.