title: Prepend sys.path from shell?
body: <p>If You want to use given <code>python</code> binary You can prepend <code>PATH</code>.</p>
  
  <p>If You want to use given <code>libpython</code> You can prepend <code>LD_LIBRARY_PATH</code></p>
  
  <p>Now suppose You want to use given package directory. I tried <code>PYTHONPATH</code> -- but it doesn't work:</p>
  
  <pre><code>$ python -c 'import sys; print sys.path[:2]'
  ['', '/home/boris/.local/lib/python2.7/site-packages']
  $ PYTHONPATH="/home/boris/test/lib/python2.7/site-packages" python -c 'import sys; print sys.path[:2]'
  ['', '/home/boris/.local/lib/python2.7/site-packages']
  </code></pre>
  
  <p>In order to do that You'd have to do either in script:</p>
  
  <pre><code>import sys
  sys.path.insert(0, "/home/boris/test/lib/python2.7/site-packages")
  </code></pre>
  
  <p>or make the special <code>usercustomize.py</code> in default <code>site-packages</code> with the same contents.</p>
  
  <p>Is there a way to modify <code>sys.path</code> from the shell?</p>
  
  <p>The behaivior I'm looking for is:</p>
  
  <pre><code>$ python -c 'import sys; print sys.path[:2]'
  ['', '/home/boris/.local/lib/python2.7/site-packages']
  $ your-shell-command
  $ python -c 'import sys; print sys.path[:2]'
  ['/home/boris/test/lib/python2.7/site-packages', '']
  </code></pre>
  
  <p><strong>Edit</strong>:</p>
  
  <p>I can see no harm if the dir will be second:</p>
  
  <pre><code>['', '/home/boris/test/lib/python2.7/site-packages']
  </code></pre>
  
  <p>but </p>
  
  <pre><code>~: PYTHONPATH="/home/farhad" python -c 'import sys; print sys.path[:2]'
  ['', '/home/boris/.local/lib/python2.7/site-packages']
  </code></pre>
  
  <p>doesn't work for me. Probably because I have <code>usercustomize.py</code> (see I also want <code>~/.local</code> libs before system-wide ones).</p>