Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update python to latest version and set as default

I am currently on ubuntu 18.04.

My default python version is Python 3.7.9

I wanted to upgrade it to Python 3.9.2 and set it as default python version

How do I do that ?

like image 466
bad_coder9042093 Avatar asked Jun 09 '26 06:06

bad_coder9042093


1 Answers

Install Python normally with the deadsnake PPA:

sudo add-apt-repository ppa:deadsnakes/ppa
sudo apt update
sudo apt install python3.9

Check if you can access Python:

python3.9 --version

If so, create a symlink to set it as "default":

sudo mv /usr/bin/python /usr/bin/python3.7
sudo ln -s $(which python3.9) /usr/bin/python
like image 109
Héliton Martins Avatar answered Jun 10 '26 19:06

Héliton Martins