Python – Install pip and virtualenv and distribute without sudo access

Recently I started to so some dev on python and noticed that on the server that I was going to do the work I don’t have sudo access.  In the past, this has not been an issue, but in this case getting sudo access is almost impossible and not doable.  So my only option is being able to run pip (to install python packages) as an user.

After painfully researching on how to successfully do this, I was able to make it work.  I hope that this helps others in the future. Good luck!

  1. Make sure that you have python installed
    which python
  2. Download latest version of virtual environment (virtualenv)
    wget https://pypi.python.org/packages/d4/0c/9840c08189e030873387a73b90ada981885010dd9aea134d6de30cd24cb8/virtualenv-15.1.0.tar.gz#md5=44e19f4134906fe2d75124427dc9b716
    
  3. Unpack source tarball
    tar -xzf virtualenv-15.1.0.tar.gz
  4. Create your package environment
    python virtualenv-15.1.0/virtualenv.py py-packages
  5. Delete the virtual environment folder
    rm -rfv virtualenv-15.1.0
  6. Install virtualenv into your environment.  You can use the package that you downloaded or using pip.
    py-packages/bin/pip install virtualenv-15.1.0.tar.gz

    or

    py-packages/bin/pip install virtualenv
  7. If you want to clone environments you can do the following
    py-packages/bin/virtualenv py-clone1

Sources:
http://stackoverflow.com/questions/4324558/whats-the-proper-way-to-install-pip-virtualenv-and-distribute-for-python
https://pypi.python.org/pypi/virtualenv
https://packaging.python.org/installing/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.