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
up vote 3 down vote accepted

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?

  • Looks like with your command I successfully installed python 2. All that's different from your command is that it's just "apt" instead of "apt-get" – Mithrandir Sep 23 '17 at 12:49
  • the latest versions usually don't come with the distribution, if you need them I think you have to install from source. – lapisdecor Sep 23 '17 at 13:02
  • I have updated my answer to include installation from source. – lapisdecor Sep 23 '17 at 13:11
  • I consider your answer correct. Because it basically solved my problem. (Somehow) Thanks! :) – Mithrandir Sep 24 '17 at 14:59

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.