0

I checked my system to see which Python is installed. I realized it was version 2.7.12. Than I downloaded the last version from Python.org which is 3.6.5. Now I have a tar.xz archive file that I extracted to somewhere (currently "Downloads" folder). Now what? What should I do? Which file should I double-click to install?

Note: I also tried sudo apt-get install python3 which seemed to do things (commands running in terminal like in Matrix) but at the end when I rechecked the Python version it was the old 2.7.12 version. Any suggestions?

  • 1
    try which python in terminal and see if it returns /usr/bin/python then do which python3 and see if it returns /usr/bin/python3 .. if so .. they are both installed .. my system has both .. if I want python3 .. I run python3 command. – John Orion Mar 29 '18 at 19:12
  • 1
    if I do python --version I get Python 2.7.12 returned and if I do python3 --version I get Python 3.5.2 returned ,,, not the "latest" but the latest for Ubuntu's install :D – John Orion Mar 29 '18 at 19:18
  • oh .. sorry .. not a python guy so .. that was just a thought .. lol but sounds like its not look upon well ... :D I will remove the thought :D – John Orion Mar 29 '18 at 19:26
  • 2
    DON'T UNINSTALL any Python versions that you will find with your Ubuntu installation, it will break your system. If you want the latest Python version take a look at this – sinecode Mar 29 '18 at 19:26
  • 2
    Please note that Python (both 2 and 3) are dependencies of important components of your Ubuntu system, like e.g. your package manager apt and many other things. You really don't want to mess your system up by removing one of these, setting them to an incorrect version (Python 2 and 3 are not compatible, one generally can't run scripts for the other without some adaption) or breaking them in any other way. Just search this site for questions of people who messed it up, you'll find many. Not few of them end with a system reinstall. – Byte Commander Mar 29 '18 at 19:27
  • ahh yeah .. sorry didn't think of dependencies yeah .. my thought would have trashed the system :D .. glad you were here to intervene :D – John Orion Mar 29 '18 at 19:28
  • 1
    If anyone wants to use python3 with python command its safe to use this command echo alias python=python3 >> ~/.bash && source ~/.bashrc. Just do it and don't remove or symlink /usr/bin/python at all! – Ali Razmdideh Mar 29 '18 at 19:31
  • yes thanks much better solution ... I jumped the gun and wasn't thinking of the consequences – John Orion Mar 29 '18 at 19:32

2 Answers2

1

The One right way to install python3 is

sudo apt-get install python3

or

sudo apt install python3    

Whether you use apt or apt-get doesn't matter in this case; it is just a personal habit. apt is a front-end for apt-get but for this command there's no difference, so both are fine.

Once installed you have the new command python3.

Python is somehow special in that there are two major versions: python2 and python3. When you install or update (or call) python you'll get the python2 line.

Some time ago the Python developers decided to release a completely new version of Python with new features and new syntax. To not break existing programs, this new version is called python3. So it's completely safe (and usual) to have both python (V2) and python3 installed at the same time. Some of your existing programs will use python (V2) and some of them will use python3. The majority will currently use python (V2) (because they aren't rewritten yet to comply with python3's syntax), so do NOT uninstall python (V2).

See also How can I remove python 2.7 after installing python 3.3?. The question is five years old but still valid. The outcome is don't!

PerlDuck
  • 13,335
0

Since you have downloaded the source tar files, You have to use the configure, make and make install utilities. As demonstrated here. Change to the extracted directory run those commands. you may leave the --prefix part if you want to replace the system's current installed Python version.