What's the difference between the keywords 'python' and 'python3' in command lines?

14,557

Solution 1

You can install multiple versions of python simultaneously in your system. Currently, python versions 2.x.x and 3.x.x is installed in your system.

Python3 is installed alongside with python(2) because some apps may still have a dependency on older python(2).

So python will refer to version 2.x.x and python3 will refer to version 3.

You can confirm the versions by:

python --version
python3 --version

Solution 2

Multiple versions of Python can be installed alongside each other and which version of Python to use can be selected by the user. The command python starts the interactive Python 2.x interpreter and python3 starts the interactive Python 3.x interpreter. For example:

C:\Windows\system32> python
Python 2.7.15rc1 
>>> 2+3
5

Many Python packages are packaged in separate versions for Python 2.x and Python 3.x and can also be installed alongside each other.

Python can run scripts interactively in a REPL. A read–eval–print loop (REPL), also termed an interactive top level or language shell, is a simple, interactive computer programming environment that takes single user inputs (i.e. single expressions), evaluates them, and returns the result to the user. Installing IPython allows the user to run blocks of code and scripts interactively in a more user-friendly way. Installing IPython 2.x alongside IPython 3.x gives the user the capability of interactively running blocks of both Python 2.x code and Python 3.x code.

Share:
14,557

Related videos on Youtube

milkwood1
Author by

milkwood1

Updated on September 18, 2022

Comments

  • milkwood1
    milkwood1 over 1 year

    I've seen two ways to open a python script using the commandline, these are:

    python foo.py 
    

    and

    python3 foo.py 
    

    I know, there are python2 etc, but what does python without a version do then and why did I see it recently?

  • Sunil Garg
    Sunil Garg over 3 years
    i have installed version 3.7.8. i am not able to run python3.. how can i do that?