이근윤
이근윤

Reputation: 21

How to set python3 as default

I recently installed python3.9.6 on ubuntu and it all seemed to work but when enter python3 on the terminal it shows python3.8.5, not python3.9.6 I want to type in python, python3, or python3.9 to open python3.9.6 can someone help me?

Upvotes: 0

Views: 8306

Answers (2)

David Camp
David Camp

Reputation: 340

You could try adding a permanent alias:

  1. Open your .bashrc file: vim ~/.bashrc

  2. Add this to the end of the file:

alias sudo="sudo " (credit to https://askubuntu.com/a/22043)

alias python="INSERT-PATH-TO-PYTHON-EXE-HERE"

alias python3="INSERT-PATH-TO-PYTHON-EXE-HERE"

alias python3.9="INSERT-PATH-TO-PYTHON-EXE-HERE"

  1. If you have any of the following: .bash_aliases, .bash_login, .profile. Add to it instead
  2. Reload .bashrc: source ~/.bashrc

Upvotes: 1

Dinuda Yaggahavita
Dinuda Yaggahavita

Reputation: 990

Check python version on terminal - python --version

Get root user privileges. On terminal type - sudo su

Write down the root user password.

Execute this command to switch to python 3.6.

update-alternatives --install /usr/bin/python python /usr/bin/python3 1

Check python version - python --version

Upvotes: 2

Related Questions