If you require Python 2.7, you will need to install it to your account unless you have a VPS or dedicated server. To do that, you will need to SSH to the server. For more information on how to do this, please see the articles linked below.
Once you have SSHed to the server, you will need to make a directory to store your local installation, then switch to that directory.
[user@server ~]# mkdir dev
[user@server ~]# cd dev
You will then need to download and extract the Python sourcecode. To do that, run the following commands:
[user@server ~/dev]# wget https://www.python.org/ftp/python/2.7/Python-2.7.tgz
[user@server ~/dev]# tar xzf Python-2.7.tgz
[user@server ~/dev]# cd Python-2.7
With the source code extracted, it’s time to build it.
[user@server ~/dev/Python-2.7]# ./configure --prefix=$HOME/dev && make && make install
This will compile Python and leave the actual binary at /home/USER/dev/bin/python. We’re almost done. Now it’s time to install pip so you can install extra Python libraries.
[user@server ~/dev/Python-2.7]# wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
[user@server ~/dev/Python-2.7]# ~/dev/bin/python get-pip.py
Once pip is installed, it will be located at /home/USER/dev/bin/pip. If you don’t want to type the full path each time, you can add it to your shell’s path. To do that, you will need to add the following line to your .bashrc file:
If you are unaware of how to modify this file, you can run the following command to add it for you:
[user@server ~]# echo "export PATH=\"$PATH:~/dev/bin\"" >> ~/.bashrc
After you have added this line to the .bashrc, close your SSH session and connect again. You will now be able to simply execute python or pip without needing the full path.