In almost all cases, this is a bad idea. Changing the system Python can and quite often will break some other packages depending on the previous environment or version. Upgrading from Python 3.10 to 3.13 means quite a few things have been changed and/or removed, making such problems likely.


So, how can you use a more modern version of Python?

One way ist the way you have already gone, installing it and accessing it via python3.13.

Another way is using the deadsnakes PPA, see e.g. this answer by Hannu (but refrain from overriding your system default).


And then there are multiple ways to get access to a specific Python version within a specific project, here is a small selection:

  1. Pyenv is the classic solution for this. It allows you to download and install basically any Python version (even alpha and beta) and activate them dynamically or use them as the base for a virtual environment.
  2. UV, a upcoming Python dependency manager, can manage Python versions as well. You just have to specify the desired Python version in a .python_version file in your project root directory.
  3. Conda, another dependency manager, but not limited to Python, can also manage multiple Python versions.
Answer from Graipher on askubuntu.com
🌐
PhoenixNAP
phoenixnap.com › home › kb › sysadmin › how to update python on windows, linux, and mac
How to Update Python on Windows, Linux, and Mac
December 18, 2025 - Update Python to access security updates, bug fixes, and new features. This tutorial covers Windows, macOS, and Linux updates.
🌐
CloudBytes
cloudbytes.dev › snippets › upgrade-python-to-latest-version-on-ubuntu-linux
Upgrade Python to latest version (3.13) on Ubuntu Linux or WSL2
January 6, 2025 - This is a short guide on how to upgrade your Python to the latest version (Python 3.13) on Ubuntu Linux and solve associated issues.
Discussions

how to update python version?
Don't mess around with the system interpreter. You don't want to upgrade your version of Python. Instead, you want to install a specific version of Python alongside the current version. The deadsnakes ppa is a way to accomplish this, and I did so on pop_os for multiple years without issue. A better way is to use pyenv which will let you install as many versions as you want. Their README is extensive and walks you through how to install a new version. You will likely need to install some dependencies, but again, this is well documented . The behavior you're experiencing is expected and desirable with use of the deadsnakes ppa. You should be required to type python3.12 if you want version 3.12. If you want to use version 3.12 for some project, then create a virtual environment with it. cd your/project/path python3.12 -m venv .venv source .venv/bin/activate python --version More on reddit.com
🌐 r/pop_os
4
1
July 14, 2024
Update python on linux 2.7 to 3.5 - Stack Overflow
So I updated python using these instructions: sudo apt-get install build-essential checkinstall sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-devlibsqlite3-dev tk-dev libgdbm-... More on stackoverflow.com
🌐 stackoverflow.com
How to update Python version in Terminal? - Stack Overflow
I've updated my version of Python to 3.11, but Terminal is printing different versions, depending on what command I enter. Entering python3 --version prints Python 3.9.13. Entering python --version More on stackoverflow.com
🌐 stackoverflow.com
linux - How do I update a Python package? - Stack Overflow
I'm running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.20.2). The 0.19.1 packa... More on stackoverflow.com
🌐 stackoverflow.com
🌐
DataCamp
datacamp.com › tutorial › pip-upgrade-python
How to Upgrade Pip and Python in Windows, MacOS, and Linux | DataCamp
December 23, 2025 - Read our step-by-step instructions for performing a Pip upgrade Python process on Windows, macOS, and Linux. Keep your environment up-to-date and compatible.
🌐
Python Central
pythoncentral.io › how-to-update-python
How to Update Python | Python Central
February 5, 2025 - All you have to do is type the right selection number, and you will have updated Python to the newest version on your Linux machine.
Top answer
1 of 6
19

In almost all cases, this is a bad idea. Changing the system Python can and quite often will break some other packages depending on the previous environment or version. Upgrading from Python 3.10 to 3.13 means quite a few things have been changed and/or removed, making such problems likely.


So, how can you use a more modern version of Python?

One way ist the way you have already gone, installing it and accessing it via python3.13.

Another way is using the deadsnakes PPA, see e.g. this answer by Hannu (but refrain from overriding your system default).


And then there are multiple ways to get access to a specific Python version within a specific project, here is a small selection:

  1. Pyenv is the classic solution for this. It allows you to download and install basically any Python version (even alpha and beta) and activate them dynamically or use them as the base for a virtual environment.
  2. UV, a upcoming Python dependency manager, can manage Python versions as well. You just have to specify the desired Python version in a .python_version file in your project root directory.
  3. Conda, another dependency manager, but not limited to Python, can also manage multiple Python versions.
2 of 6
8

A simple "clean" way to install a more recent Python3 than present in Ubuntu is the deadsnakes ppa:

Howto set the default version:
https://www.debugpoint.com/install-python-3-12-ubuntu/
... at "Use Python 3.12 as the default Python3"

The basics for installation:

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

https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa
The ppa gets updated, so a more recent one may well be present;
also ALWAYS verify the correctness of what is stated above.

🌐
Reddit
reddit.com › r/pop_os › how to update python version?
Wie aktualisiere ich die Python-Version? : r/pop_os
July 14, 2024 -

Hey all,

I'm trying to code in Python but I'm slightly agitated by the fact that I'm running an outdated version of python, 3.10, instead of 3.12. 3.10 came preinstalled on my system. When I try using sudo apt install python3 it says my python package is already up to date. so instead, i tried installing python 3.12 with the deadsnakes ppa (i was warned that this can cause issues on popos but quite frankly, i do not care) which technically worked, i do have python 3.12 installed on my system now, but in my terminal, typing python or python3 both lead to the old version, python 3.10, being launched. to launch 3.12, i have to type python3.12 in the terminal.

so... how can i just... update python? I don't want 3.10 on my system anymore.

if anyone can help, i will be very grateful.

🌐
Kanaries
docs.kanaries.net › topics › Python › how-to-update-python
How to Upgrade Python on Windows, Mac, Linux? – Kanaries
August 18, 2023 - Open Terminal and type brew update && brew upgrade python to update Python to the latest version. Depending on your Linux distribution, you may need to use different methods to update Python.
Find elsewhere
🌐
The Hitchhiker's Guide to Python
docs.python-guide.org › starting › install3 › linux
Installing Python 3 on Linux — The Hitchhiker's Guide to Python
$ sudo apt-get install software-properties-common $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt-get update $ sudo apt-get install python3.8 · If you are using other Linux distribution, chances are you already have Python 3 pre-installed ...
🌐
Leapcell
leapcell.io › blog › de › wie-man-python-aktualisiert-eine-umfassende-anleitung
Wie man Python aktualisiert: Eine umfassende Anleitung | Leapcell
July 25, 2025 - Dieser Leitfaden bietet schrittweise Anleitungen zur Aktualisierung von Python unter Windows-, macOS- und Linux-Systemen. Vor der Aktualisierung ist es wichtig, Ihre aktuelle Python-Version zu kennen: ... Windows: Öffnen Sie die Eingabeaufforderung. ... Geben Sie python --version oder python3 --version ein und drücken Sie die Eingabetaste. Die installierte Python-Version wird angezeigt. Es gibt zwei Hauptmethoden, um Python unter Windows zu aktualisieren: mit dem offiziellen Installationsprogramm oder über den Microsoft Store.
Top answer
1 of 12
85

As others already noted, bare sudo apt-get install package will install latest available version, replacing the older one if needed.

But with some software (among which is Python) the situation is somewhat different. Some major, very- and incompatibly-different versions get their own packages. For instance, Python 2.6, Python 2.7, Python 3.1 all live in separate packages on Ubuntu.

Of particular importance is the fact that one of Ubuntu policies is to extensively use Python for writing end-user software. So in fact, fairly large part of the system is written in Python. At the moment, the code runs on Python 2.6 — so this version is the default upon installation; and the code won't easily run on, say, Python 2.7 — because incompatibilities exist. To switch the system to Python 2.7 there needs to be done a piece of work, consisting of updating and re-testing all the scripts. This can't be done easily; that is, you can't just "switch" your system to Python 2.7 and delete the older version.

But. If you don't care about fancy gears of your system and just need newer Python — see no obstacles. Go and sudo apt-get install python3 and code for 3.x Python bravely; just remember to launch your scripts with python3 and use #!/usr/bin/env python3 shebang line.


Upd: I keep seeing this upvoted; notice that this is a fairly old answer, things have changed.


What to learn next

From a superuser perspective (not Python developer's), the next things I'd suggest learning to use:

  • pip/pip3/python3 -m pip — this is the npm for Python. Quick tip: try pip3 install --user howdoi (may need to apt install python3-setuptools python3-pip once, before that works). Then for example, howdoi --all compile python3 ubuntu.

  • The virtualenv tool. It's 100% developer-oriented, but you'll likely need to use it (perhaps underneath a few wrappers, such as tox or pipx) to work with people's source packages.
    Ruby's bundler or Cabal sandbox may be familiar analogues.

  • The conda tool — which is a totally separate python package repository and installer (think: fork of PyPi).

There's humongous variety of tools in the Python ecosystem in 2020. At the very least, make yourself comfortable with pip before going deeper.

Basic pitfalls

For the brave but unwary, a few classic pitfalls when trying to manually set up a newer CPython on Ubuntu.

  • Leave /usr alone; you can look but you don't touch. Leave it to dpkg, save yourself some confusion. You have the whole /usr/local at your disposal:

    sudo chown -R `whoami` /usr/local
    pip3 install --prefix=/usr/local pydf
    
  • Compiling CPython from source is well-explained on the web; just don't forget your /usr/local prefix. This is the best way to manually test patches and/or pre-releases (those alpha-, rc- builds) of CPython itself. To wipe built artifacts, you can just rm -rf /usr/local/*; sudo ldconfig.

  • Finding a PPA is decent option too; keep in mind that a PPA is just someone else's private build. Look for credible PPAs with CI/CD running.

2 of 12
20
sudo apt-get install python 3.3.3

this is for python(3.3.3) for different version the corresponding version number should be used.

Top answer
1 of 5
6

A terminal in a unix-based OS (including Darwin / MacOS and Linux) will search for the command you have typed in several places, in order, and the first match found will stop the search from finding other possible commands with the same name.

To simplify the answer, I'll limit this to the bash shell as I don't use ZSH, but I think the answer should be similar in both shells.

After you type in a line of input and hit enter, your shell will modify its input so that it expands variable interpolations and such things and then will take the first token (first "word") and search for that word as a command name.

Commands can be found in several places, from builtin commands, to aliases, to shell functions and if the command can't be found there, the shell will begin looking at specific locations in your filesystem to look for files that are named the same as your command. The first match wins, so if you have several pythons in your PATH, the first one will be the one that is selected.

The set of locations in your filesystem the shell will look for the command is stored in an environment variable called PATH in the shell and is generally available to view and set.

to see what your path is:

echo ${PATH}

or. for slightly easier reading:

echo ${PATH} | sed 's/:/\n/g'

which python will let you see what python version your shell is finding first in the PATH and type python will let you know if for some reason you have a function or alias named python that happens to overshadow your filesystem python executables.

Also, bash maintains an internal hash table of where it has previously found commands. So if you type python and bash finds it in /usr/bin/python, then it will remember that for the rest of the session. If you'd like it to look again, because perhaps you have installed a new python you expect it to find first, you can type hash -r to reset the hash table to a blank new one.

All that being said, if you are starting to develop in Python, you're going to need to handle different versions of Python.

To start down that road, check out:

  • asdf
  • pyenv

I recommend asdf as it can work for many things, not just python. Also, you'll probably want a decent dependency manager sooner rather than later for your project, so I'd check out poetry and pipenv:

  • Poetry
  • Pipenv
2 of 5
2

I just had the same problem and I'm sharing this in case this helps anyone else. Note: I am on a Windows computer. Initially, I thought all I had to do was download the newest version of Python from the website. However, my terminal was printing:

python --version Python 3.12.1

python3 --version Python 3.10.3

py --version Python 3.13.1

So the first thing I did was type scoop install python because I thought it might be a problem with that command line installer. But even when I did that, it was now printing out:

python --version Python 3.12.1

python3 --version Python 3.13.1

py --version Python 3.13.1

So eventually I made my way to my environment variables and removed an install of Python 3.12 from my PATH for my local user profile. Now all versions of Python correctly print their intended version!

python --version Python 3.13.1

python3 --version Python 3.13.1

py --version Python 3.13.1

🌐
FOSS Linux
fosslinux.com › home › programming › how to update and manage python versions on linux
How to Update and Manage Python Versions on Linux
August 2, 2024 - In this guide, I’ll walk you through updating Python on Ubuntu, Fedora, and CentOS. Each method includes detailed steps and examples, ensuring you can follow along regardless of your Linux distribution.
🌐
4Geeks
4geeks.com › how-to › how-to-update-python-version
How to update Python version?
July 16, 2025 - 1# On windows Powershell 2$ choco upgrade python -y 3 4# MacOs homebrew with pipenv 5# you would need to install python first 6$ pyenv install 3.9.2 7 8# linux 9$ sudo add-apt-repository ppa:deadsnakes/ppa 10$ sudo apt update 11$ sudo apt install python3.9
🌐
Reddit
reddit.com › r/linuxmint › update python without damaging ubuntu
Python aktualisieren ohne Ubuntu zu beschädigen
April 13, 2025 -

Hi there. I'm trying to run a program that transfers Spotify data to YT music, and the process has been running smoothly so far. However, after installation when setting up the GUI, I get a syntax error. After looking around the "Issues" tab on Github, it seems the problem is because my Python version is outdated (mine is 3.8.10 and based on the comments, the command needs to have Python 3.10 or above). When I started searching on how to update python on Linux, I noticed it was discouraged because it can screw with the software. Is there any way to update Python without damaging my computer and/or Linux? Thanks a lot in advance. Also I am very much a noob in computer knowledge, and english is not my first language, so apologies in advance if I am using the wrong terms for things.

Some info that may be of use:

Git Program: https://github.com/linsomniac/spotify_to_ytmusic

The installation uses a virtualenv, dunno if that affects the error.

All other steps from the readme work flawlessly, only problem arises from setting up the gui.

My Python version is 3.8.10

The response I saw about the issue:

You are likely running a version of Python older than 3.10, where the "match" syntax was introduced. Please update to python 3.10 or newer.

Here's the command and response:

CMD: python3 spotify2ytmusic/ytmusic_credentials.py

Response:

raceback (most recent call last):

File "/usr/lib/python3.8/runpy.py", line 185, in _run_module_as_main

mod_name, mod_spec, code = _get_module_details(mod_name, _Error)

File "/usr/lib/python3.8/runpy.py", line 144, in _get_module_details

return _get_module_details(pkg_main_name, error)

File "/usr/lib/python3.8/runpy.py", line 111, in _get_module_details

__import__(pkg_name)

File "/home/lucas/spotify_to_ytmusic/spotify2ytmusic/__init__.py", line 3, in <module>

from . import cli

File "/home/lucas/spotify_to_ytmusic/spotify2ytmusic/cli.py", line 7, in <module>

from . import backend

File "/home/lucas/spotify_to_ytmusic/spotify2ytmusic/backend.py", line 275

match yt_search_algo:

^

SyntaxError: invalid syntax

System Information: https://ibb.co/0jKRP9WH

🌐
Linux Mint Forums
forums.linuxmint.com › board index › main edition support › beginner questions
[SOLVED] updating python on linux mint 21.3 - Linux Mint Forums
April 13, 2024 - coffee@max:~$ python2 -V Python 2.7.18 Both versions are installed for compatibility I do believe. If its available in the updates go a head and update it. - List your hardware Profile: inxi -Fxpmrz MeshCentral * Virtualbox * Debian * InvoiceNinja * NextCloud * Linux since kernel 2.0.36
🌐
Com
qastack.com.de › superuser › 241865 › updating-python-on-ubuntu-system
Aktualisieren von Python auf Ubuntu-System
[Lösung gefunden!] Wie bereits erwähnt, sudo apt-get install packageinstalliert bare die neueste verfügbare Version und ersetzt bei Bedarf…