Python: Installing PIP and Virtualenv without root

Update (2018): These days I just use anaconda which I find easier to work with!  As far as I’m aware the instructions below are still accurate, please let me know if this is not the case.

Using virtualenv in combination with pip is a great way to run isolated python environments with all kinds of packages. However if the system you are using does not have pip, easy_install or virtualenv installed system-wide, it’s a little bit tricky to set up.

With some experimentation and some googling (stackoverflow), here’s a quick guide to do it. I’m assuming you have python already on the system.

First, we need ez_setup. The following commands grab the scripts and install them to ~/.local/bin:

wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py
python ez_setup.py –-user

Now we can install pip in the same way:

curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py –-user

Now we have pip, and just need to add it to the path variable (add it to your .bashrc):

export PATH=~/.local/bin:$PATH

Finally, we can install packages. Get virtualenv:

pip install --user virtualenv

Now you can set up virtual environments for python, which is well-documented here.

Advertisements

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s