title: How to install python modules in a local directory? --user and exporting pythonpath isn't working
body: <p>I don't know very much about python but would like to install some python modules in a local directory on a server on which I don't have sudo access.</p>
  
  <p>I start by going into my desired directory (not root) and create the directory tree needed to store my custom modules</p>
  
  <pre><code>cd /root/example/sub-example
  mkdir -p local/lib/python2.7/site-packages
  </code></pre>
  
  <p>I then export this local path to <code>PYTHONPATH</code></p>
  
  <pre><code>export PYTHONPATH=$PYTHONPATH:/root/example/sub-example/local/lib/python2.7/site-packages
  </code></pre>
  
  <p>I then make a new sub-directory to store the python package while extracting</p>
  
  <pre><code>mkdir example-python-directory
  cd example-python-directory
  wget http://example-python-package
  tar -xvf example-python-package.tar.gz
  cd example-python-package
  </code></pre>
  
  <p>Last, I run the setup.py script with the <code>--user</code> flag to try to get it to install in my specified <code>/local</code> directory</p>
  
  <pre><code>python setup.py install --user
  </code></pre>
  
  <p>The problem is, nothing is installed in my <code>/root/example/sub-example/local/lib/python2.7/site-packages</code> directory, and instead I find that I now have a new directory at root: <code>/root/.local/lib/python2.7/site-packages</code></p>
  
  <p>Is there a way to prevent this? I feel like my lack of Python knowledge is causing me to make some silly error that is probably obvious to others. Thanks for the help!</p>