title: Sorting sys.path: first virtualenv, then /usr
body: <p>Why does <code>sys.path</code> contain <code>/usr/...</code> before directories from my virtualenv?</p>
  
  <p>I create the virtualenv with <code>--system-site-packages</code></p>
  
  <p>The <code>sys.path</code> looks like this at the moment:</p>
  
  <pre><code>/home/my-virtualenv/src/foo
  /usr/lib/python2.7/site-packages        &lt;--- /usr paths should be below 
  /usr/lib64/python2.7/site-packages
  /home/my-virtualenv/lib/python27.zip
  /home/my-virtualenv/lib64/python2.7
  /home/my-virtualenv/lib64/python2.7/plat-linux2
  /home/my-virtualenv/lib64/python2.7/lib-tk
  /home/my-virtualenv/lib64/python2.7/lib-old
  /home/my-virtualenv/lib64/python2.7/lib-dynload
  /usr/lib64/python2.7
  /usr/lib/python2.7
  /usr/lib64/python2.7/lib-tk
  /home/my-virtualenv/lib/python2.7/site-packages
  </code></pre>
  
  <p>I want all paths outside my virtualenv (<code>/usr...</code>) to be below the paths of the virtualenv.</p>
  
  <p>Otherwise crazy things happen: I install a package with pip. Pip tells me that the new version is installed (<code>pip freeze | grep -i ...</code>) but the import does use the one from <code>/usr/lib/python2.7/site-packages</code></p>
  
  <p>I can't use <code>--no-site-packages</code> in my context.</p>
  
  <p>Is there a way to sort <code>sys.path</code>?</p>
  
  <p><strong>Why I use system-site-packages</strong></p>
  
  <p>There seems to be no straight forward way to make single libraries from the global site-packages available in the virtualenv. See this question:
  <a href="https://stackoverflow.com/questions/19228198/make-some-modules-from-global-site-packages-available-in-virtualenv">make some modules from global site-packages available in virtualenv</a></p>
  
  <p>There are packages like python-gtk which are very hard to install in a virtualenv.</p>