How to install newer version of python in ubuntu?
python
ubuntu
python3
Software and digital electronics / IT
2024-05-27 06:23
I am having a python 3.8 on my Ubuntu server.
python3 --version
Python 3.8.10
My ubuntu is 20.04 focal:
lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.6 LTS
Release: 20.04
Codename: focal
I am going to install a python package via pip which requires me to have python 3.9. How can I upgrade my server python to 3.9 version?
add comment
Answered by robin
2024-07-24 04:51
To upgrade to version 3.9 of python, you do need to add any 3rd party repository, it is as simple as
sudo apt update && sudo apt upgrade sudo apt install python3.9
You probably want to make python3.9 as your default python version:
sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1 sudo update-alternatives --config python3 python3 --version
Disclaimer
Changing your default python version can easily mess up with your Ubuntu server. Many essential software may not run anymore or may behave differently. If I was instead of you, I would consider finding an alternative to the package instead of touching my server essential services.
add comment