How to Change the Default Python Version in Linux

If you want to change the default version of python in your Linux machine, then you are in the right place.

You can change the default version of Python in Linux by using the following steps:

Check the available versions of Python using the command

 python3 --version

or

python --version

Use the following command to create a symbolic link for the desired version of Python:

sudo ln -sf /usr/bin/python3 /usr/bin/python

or

sudo ln -sf /usr/bin/python2 /usr/bin/python

Verify the change by running the command.

python --version

Note: This change may affect the system-wide use of Python and potentially break other installed packages that rely on a specific version of Python. Therefore, it’s recommended to use virtual environments to isolate different Python projects and their dependencies.

Leave a Comment