Ubuntu: Why do I have two versions of Python?



Question:

I am very new to Ubuntu. If I use IDLE I am using Python 3.3.2+, whereas if I go the terminal and type python --version it says I am using 2.7.5+. As these versions are not compatible with each other, I can not run code created in IDLE from the Terminal. So how do I make sure that I am only using one version of python in ubuntu.


Solution:1

Python 3 has introduced a number of backwards incompatible changes. That is why your python 3 code does not run without error when using the python command. To answer your question "how do I make sure that I am only using one version of python in ubuntu", you should note that the two python versions live in peaceful cohabitation. They can coexist. In a terminal just use the command python to run your python 2 code and python3 to run your python 3 code.

In response to Rahil's comment on why Ubuntu ships with two python versions:

  1. A lot of software was written for python 2 and is not "ported to" or adapted for python 3 yet. There is also some software in Ubuntu that still needs python 2. In the future this will most likely no longer be the case.
  2. There are quite a number of python third party packages (bits of software that you can reuse in your own software or toolbelt). Not all of these packages have been converted to python 3 either.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »