close

How to switch Python versions in Terminal?

Hello Guys, How are you all? Hope You all Are Fine. Today We Are Going To learn about How to switch Python versions in Terminal in Python. So Here I am Explain to you all the possible Methods here.

Without wasting your time, Let’s start This Article.

Table of Contents

How to switch Python versions in Terminal?

  1. How to switch Python versions in Terminal?

    The simplest way would be to add an alias to python3 to always point to the native python installed.

  2. switch Python versions in Terminal

    The simplest way would be to add an alias to python3 to always point to the native python installed.

Method 1

The simplest way would be to add an alias to python3 to always point to the native python installed. Add this line to the .bash_profile file in your $HOME directory at the last,

alias python="python3"

Doing so makes the changes to be reflected on every interactive shell opened.

Method 2

You can just specify the python version when running a program:

for python 2:

python filename.py

for python 3:

python3 filename.py

Summery

It’s all About this issue. Hope all Methods helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which Method worked for you? Thank You.

Also, Read