title: Path precedence over Python modules in different install locations
body: <p>On a Mac OS Darwin Kernel Version 16.6.0 x86_64 I have two versions of matplotlib installed. The one that came with the system in:</p>
  
  <pre><code>&gt; ls /System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/ | grep matplotlib
  matplotlib/
  matplotlib-1.3.1-py2.7-nspkg.pth
  matplotlib-1.3.1-py2.7.egg-info/
  </code></pre>
  
  <p>and I recently installed a new matplotlib version:</p>
  
  <pre><code>&gt; pip install --user -U matplotlib
  &gt; ls ~/Library/Python/2.7/lib/python/site-packages/ | grep matplotlib
  matplotlib/
  matplotlib-2.0.2-py2.7-nspkg.pth
  matplotlib-2.0.2.dist-info/
  </code></pre>
  
  <p>However, it seems that always the system version of matplotlib is imported and not the one I installed. </p>
  
  <pre><code>from __future__ import (print_function)
  import sys
  import matplotlib
  
  print('sys.path:', sys.path)
  print('matplotlib version:', matplotlib.__version__)
  print('matplotlib path:', matplotlib.__path__)
  </code></pre>
  
  <p>This prints:</p>
  
  <pre><code>sys.path: ['/my/dir/Desktop', '/my/dir/Library/Python/2.7/lib/python/site-packages/multiqc-1.0.dev0-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/spectra-0.0.7-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/click-6.7-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/PyYAML-3.12-py2.7-macosx-10.12-intel.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/simplejson-3.10.0-py2.7-macosx-10.12-intel.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/Jinja2-2.9.6-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/colormath-2.1.1-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/nose-1.3.7-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/tornado-4.5-py2.7-macosx-10.12-intel.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/MarkupSafe-1.0-py2.7-macosx-10.12-intel.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/networkx-1.11-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/backports_abc-0.5-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/certifi-2017.4.17-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/singledispatch-3.4.0.3-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/decorator-4.0.11-py2.7.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python', '/my/dir/Library/Python/2.7/lib/python/site-packages/mergevcf-1.0.1-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/PyVCF-0.6.8-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/pip-9.0.1-py2.7.egg', '/my/dir/Library/Python/2.7/lib/python/site-packages/dadi-1.7.0-py2.7-macosx-10.12-intel.egg', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/my/dir/Library/Python/2.7/lib/python/site-packages', '/Library/Python/2.7/site-packages', '/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC']
  matplotlib version: 1.3.1
  matplotlib path: ['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib']
  </code></pre>
  
  <p>If I modify the path inside the script with <code>sys.path</code>:</p>
  
  <pre><code>sys.path.insert(0, '/my/dir/Library/Python/2.7/lib/python/site-packages')
  </code></pre>
  
  <p>it loads the correct version i.e. 2.0.2.</p>
  
  <p>However, if I <code>export PYTHONPATH=$HOME/Library/Python/2.7/lib/python/site-packages:$PYTHONPATH</code> variable in the shell it defaults again to the old system version 1.3.1 of matplotlib.</p>
  
  <p>So how can I specify, outside the script, to use the user installed version of a module instead of the system one when having different versions of the same module installed?</p>