Ubuntu – Help Installing Python on Ubuntu

17.04python-2.7

I'm attempting to install both the last version of python 2 which is currently 2.7.14 according to the site, and the latest for v3, even though I don't really need it. (Just to see if I can get any version of python to work)

I only truly need python 2 in order to run an old python program on Ubuntu.

I recently tried installing both versions in the following manner, first:

sudo apt-get install python2.7

After python 2 seems installed, I tried checking the version:

python -V

However, this input returns:

-bash: python: command not found

Same with python 3:

sudo apt-get install python3.6

I get another negative output when checking for the version.

-bash: /usr/bin/python3: No such file or directory

It seems like both versions don't fully install.

I must add an important fact though, the reason why I can't get to install and use any python version on my Ubuntu system is provably because I already removed python 3 previously in this doubtfull manner:

sudo apt purge python3.5-minimal

Since:

sudo apt-get remove python3.5

Wasn't doing the job for the removal of python 3 (It still fully functioned).
I feel like I may have deleted something important while trying to propperly re-install python on my sistem.

Why I installed python 3 (Which I did get to work) if all I really need is python 2? The answer is, I didn't know I needed python 2 in order to run this python program, so I thought installing the latest version would be the wisest thing to do. However the developer informed me that the program can only run with python 2 (Once I found out I couldn't run it on 3). So I thought the best thing would be to remove python 3 entirely and install 2 instead, however this hasn't gone so well.

Could I get some orientation on how to propperly fix this mess and install python 2? All I really need is python 2 for executing a program from that version.

Specifications:

Ubuntu version: 17.04
Desired python version: 2.7.14 (Currently at the time of writing this is 
latest)

If you find my issue is not concise enough, please ask. I'll try my best at expanding the details (By editing + commenting).

Best Answer

To install python 2:

sudo apt install python

To install python 3:

sudo apt install python3

To see python version just start python

python

for python2

python3

for python3

You can also use:

python --version

or

python3 --version

To install the latest version, download it, unzip it and install primary versions of python (the one you want by default) with:

sudo make install

and install secondary versions with:

sudo make altinstall

You can also follow this answer: How do I install Python 3.6 using apt-get?

Related Question