Skip to content

Instantly share code, notes, and snippets.

@hrushikesh198
Last active September 28, 2024 14:48
Show Gist options
  • Select an option

  • Save hrushikesh198/1baffbbf106191d37e07cab266405b7a to your computer and use it in GitHub Desktop.

Select an option

Save hrushikesh198/1baffbbf106191d37e07cab266405b7a to your computer and use it in GitHub Desktop.
Python2.7, Pip, Virtualenv Installation on Mac or Linux machines for the current user without sudo access

I will show the steps using Python2.7.13 If you download a newer version it should work similarly.

cd ~
wget https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar -xzvf Python-2.7.13.tgz
cd Python-2.7.13
./configure --prefix=~ 
make altinstall

The configure and make step takes few minutes. Now python 2.7 would be present in ~/.local/bin Add this to PATH

export PATH=~/.local/bin:$PATH
python2.7  # should work fine

It is a good idea to add the export statement to ~/.bashrc file to load at login. You can also create a soft-link to python2.7 so that python command gives you 2.7 cd ~/.local/bin; ln -s python2.7 python

Lets talk about installing pip. Download the get-pip.py file and install it for the current user. It will leave pip and pip2.7 executables in ~/.local/bin.

cd ~
wget https://bootstrap.pypa.io/get-pip.py
~/.local/bin/python2.7 get-pip.py --user

Pip shows some ssl warnings. You can fix those by doing the folowing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment