Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make the "python" command in terminal, run python3 instead of python2?

Tags:

I'm just starting to learn Python and did search around a little, so forgive me if this has been asked and answered.

When running scripts through the command line/terminal, I have to type "python3" to run the latest version of Python. With Python 2.X I just use "python".

Is there a way to run Python 3 just using "python"? It may seem a little lazy, but I'm mostly just curious if it is possible or if it will break anything unnecessarily if I could in fact do it.

like image 430
Charlotteis Avatar asked Apr 13 '14 21:04

Charlotteis


People also ask

How do I enable Python 3 in terminal?

To start a Python interactive session, just open a command-line or terminal and then type in python , or python3 depending on your Python installation, and then hit Enter .

How do I change python2 to python3?

We can convert Python2 scripts to Python3 scripts by using 2to3 module. It changes Python2 syntax to Python3 syntax. We can change all the files in a particular folder from python2 to python3.


1 Answers

If you are using Linux, add the following into into ~/.bashrc alias python=python3 Restart the shell and type python and python3 should start instead of python2.

like image 125
Dan Walsh Avatar answered Sep 19 '22 15:09

Dan Walsh