3

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).

  • the double hyphen is for full word options (in this case python --version), in your case, you should be typing python -V. – S.Ith Sep 23 '17 at 12:02
  • 1
    Well, python3 is installed by default, as many default tools and apps use it. You should not remove it. You need the python-minimal package installed for /usr/bin/python. You likely don't really need 2.7.14 for an old program, and the version in current 17.04 will do fine. However, 2.7.14 is in 17.10, which will be released next month, which you should upgrade to from 17.04 (as it will be EOL in 3 months after 17.10 is released). – dobey Sep 23 '17 at 12:03
  • @S.Ith Corrected typo. The issue is still the same. – Mithrandir Sep 23 '17 at 12:12
  • @dobey I thought so... So I basically removed something which was already included. But I removed it so deeply it broke any further installation. Do I need to reinstall "python-minimal" with sudo-apt get? – Mithrandir Sep 23 '17 at 12:14
  • I think you just need to install python and python3. I also think you think you need a later version of python than you actually need. You really only need the absolute latest version in some extreme extenuating circumstances, which your old program likely doesn't meet. – dobey Sep 23 '17 at 13:19
  • I just did a clean install and upgrade of ubuntu 17.04 in a VM, and after retracing all of your steps, python 2.7.13 works ok (the version you can download using the repos). When you did the apt-get remove, you uninstalled a lot of packages, and the number grew up after the apt-get purge, though both remove and purge, leave dependencies installed with the package on installation time untouched. So it must be something else. Reinstalling python 2.7.13 should do the trick through apt install. – S.Ith Sep 23 '17 at 15:43

1 Answers1

5

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?

lapisdecor
  • 1,627