If you download a different 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
make altinstall prefix=~/.local/
The configure
and make
step takes few minutes. Now python 2.7 would be present in ~/.local/bin.
Add this to PATH. This is very important as the following steps depend on it.
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 v2.7
cd ~/.local/bin; ln -s python2.7 python
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
python2.7 get-pip.py --user
pip install virtualenv --user
cd ~
mkdir venv
cd venv
virtualenv -p ~/.local/bin/python2.7 e1
virtualenv --relocatable e1
## To use e1
source ~/venv/e1/bin/activate
## pip install some libraries inside the env e1
## To exit
deactivate
For shipping it to a different machine
Copy ~/.local
and ~/venv/e1
.
You will get your python and installed packages on a different machine inside env e1
.
It is a good idea to make a tarball and scp to save some time.