Prepend sys.path from shell?
Question: If You want to use given `python` binary You can prepend `PATH`.

If You want to use given `libpython` You can prepend `LD_LIBRARY_PATH`

Now suppose You want to use given package directory. I tried `PYTHONPATH` \--
but it doesn't work:

    
    
    $ 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']
    

In order to do that You'd have to do either in script:

    
    
    import sys
    sys.path.insert(0, "/home/boris/test/lib/python2.7/site-packages")
    

or make the special `usercustomize.py` in default `site-packages` with the
same contents.

Is there a way to modify `sys.path` from the shell?

The behaivior I'm looking for is:

    
    
    $ 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', '']
    

**Edit** :

I can see no harm if the dir will be second:

    
    
    ['', '/home/boris/test/lib/python2.7/site-packages']
    

but

    
    
    ~: PYTHONPATH="/home/farhad" python -c 'import sys; print sys.path[:2]'
    ['', '/home/boris/.local/lib/python2.7/site-packages']
    

doesn't work for me. Probably because I have `usercustomize.py` (see I also
want `~/.local` libs before system-wide ones).


Answer: For me works:

    
    
    $PYTHONPATH="/home/farhad" python -c 'import sys; print sys.path[:2]'
    ['', '/home/farhad']
    $
    

