DEV Community

Olatunji Ayodele Abidemi
Olatunji Ayodele Abidemi

Posted on

To make Python 3 the default version on Ubuntu, replacing Python 2

Here's a step-by-step guide:

  1. Open a terminal.
  2. Install the python-is-python3 package which will set Python 3 as the default when you use the python command: bash sudo apt install python-is-python3
  3. If you have multiple versions of Python 3 and want to set a specific one (e.g., Python 3.8) as the default for the python3 command, use update-alternatives:
   sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1
Enter fullscreen mode Exit fullscreen mode
  1. You can then configure the default version by running:
   sudo update-alternatives --config python3
Enter fullscreen mode Exit fullscreen mode

Follow the on-screen instructions to select the default Python 3 version.

  1. Verify the change by checking the Python version:
   python3 --version
Enter fullscreen mode Exit fullscreen mode

Top comments (0)