RaspberryPi

How to check the python version of Raspberry Pi and change to python3.

This article shows you how to check the python version of your Raspberry Pi.

It also shows how to change the version from python 2.x to python 3.x.

Contents

  • How to check current python version
  • How to change python version to python3.x

sponsored link

Check python version of Raspberry Pi

First, I will show you how to check your current python version.

You can check the current python version by entering the following command in the terminal.

python --version

In the author's environment, this is what was shown.

Python 2.7.16

sponsored link

Change the version of Raspberry Pi python to python3.

To migrate to python3, follow the steps below.

  • Check current python symbolic link
  • Remove symbolic link to python2
  • Create symbolic link to python3
  • Confirm that python version is python3.x

Check current python symbolic link

Check current python symbolic link.

Move to " /usr/bin " with the "cd" command.

cd /usr/bin

Check current python symbolic link with "ls" command.

You can check it with the "-l" option.

ls -l python*
Check python version

You can see that python used by default is the symbolic link to Python 2.7.

It also shows that python 3.7 is already installed.

To switch to python 3.7, change this symbolic link to Python 3.7.

The procedure is described in the following sections.

Remove symbolic link to python2

Remove the current python symbolic link.

Enter the following command in the terminal.

sudo unlink python

If you check with aforementioned "ls" command, you will see that the symbolic link to python 2.7 has been removed.

Symbolic link to python2.7 has been removed

Create symbolic link to python3

Create symbolic link to python3.

Enter the following command in the terminal.

sudo ln -s python3 python

If you check with aforementioned "ls" command, you can see that a symbolic link to python3.7 has been created.

Symbolic link to python3.7 has been created.

Confirm that python version is python3.x

If python3 is displayed with the version check command, you have succeeded.

python --version

In the author's environment, this is what was shown.

Python 3.7.3

sponsored link

-RaspberryPi
-