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?
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 /usr/bin/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 matplotlib.__file__ '/Library/Python/2.7/site-packages/matplotlib-override/matplotlib/__init__.pyc' matplotlib.__version__ '1.4.3'
Without the pth file and with matplotlib installed with pip
import matplotlib matplotlib.__file__ '/Library/Python/2.7/site-packages/matplotlib/__init__.pyc' matplotlib.__version__ '1.5.0'
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 numpy.__version__ '1.9.2' numpy.__file__ '/Library/Python/2.7/site-packages/numpy-override/numpy/__init__.pyc'
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 osgeo.__file__ '/Library/Frameworks/GDAL.framework/Versions/1.11/Python/2.7/site-packages/osgeo/__init__.pyc'
gdal-py2.7.pth allows to use the module as if it were in the site-package folder
Thus you don't need to "reset" the Python modules, but only choose the version to use.