This simple tutorial shows how to install Python 3.13 in Ubuntu 24.04, Ubuntu 22.04, and/or Ubuntu 20.04 LTS.
Python 3.13.0 was released on Oct 7, 2024 as the new major release that features new interactive interpreter, that supports multi-line editing, REPL-specific commands such as help
, exit
, clear
, and quit
, interactive help, history browsing, and ‘paste mode’ for pasting larger blocks of code.
CPython now has experimental support for free-threaded mode for running threads in parallel on available CPU cores, though disabled by default.
Other changes in Python 3.13.0 include:
- New interactive interpreter, features multi-line editing and color support, as well as colorized exception tracebacks.
- Experimental free-threaded build mode.
- A preliminary, experimental JIT.
- The (cyclic) garbage collector is now incremental.
- Include a modified version of mimalloc, and enabled by default if supported by the platform.
- Docstrings now have their leading indentation stripped, reducing memory use and the size of .pyc files.
- The dbm module has a new dbm.sqlite3 backend that is used by default when creating new files.
- Support for type defaults in type parameters.
- New type narrowing annotation, typing.TypeIs.
- New annotation for read-only items in TypeDicts.
- Removals of many deprecated modules: aifc, audioop, chunk, cgi, cgitb, crypt, imghdr, mailcap, msilib, nis, nntplib, ossaudiodev, pipes, sndhdr, spwd, sunau, telnetlib, uu, xdrlib, lib2to3.
For more, see the official release note.
Option 1: Install Python 3.13 from Ubuntu PPA
The popular deadsnakes PPA has built the latest Python 3.13 for Ubuntu 20.04, Ubuntu 22.04, and Ubuntu 24.04.
1. First, press Ctrl+Alt+T
on keyboard to open terminal. When it opens, run command to add the PPA:
sudo add-apt-repository ppa:deadsnakes/ppa
Type user password when it asks (no visual feedback) for sudo authentication and hit Enter to continue.
2. Then, install Python 3.13 by running command (Linux Mint needs to run sudo apt update
first to refresh package cache):
sudo apt install python3.13-full
For choice, replace python3.13
in command with python3.13-full
to also install GNU dbm database support, tkinter, as well as the IDE.
3. After installation, verify its version by running command:
python3.13 --version
4. To get pip package installer for Python3.13, just run the ensurepip
module which provides support for bootstrapping the pip installer into an existing Python installation.
python3.13 -m ensurepip --upgrade
Then verify via: python3.13 -m pip --version
, and upgrade it via python3.13 -m pip install --upgrade pip
.
Option 2: Compile Python 3.13 from source tarball
1. First, press Ctrl+Alt+T on keyboard to open terminal. When it opens, run command to install the required libraries for building Python:
sudo apt install wget build-essential libreadline-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev libffi-dev zlib1g-dev
2. Then, select download the most recent dev version of Python 3.13 (so far Python-3.13.0.tar.xz
) from the link page below:
3. Next, extract the source tarball in file manager. Then, right-click on extracted folder and select “Open in terminal” to open that folder as working directory in terminal.
4. In the pop-up terminal, configure the source via command:
./configure --enable-optimizations
For choice, you can run ./configure --help
to print more configure options.
Then, compile by starting 4 threads in parallel:
make -j4
And finally install Python 3.13:
sudo make install
Finally, verify via command: python3.13 --version
and pip3.13 --version
.
Uninstall:
For Python 3.13 installed from PPA, open terminal and run command to remove it:
sudo apt remove --autoremove python3.13
Also remove the PPA by running command:
sudo add-apt-repository --remove ppa:deadsnakes/ppa
If you compiled it from source, then try running the command below from source folder until you removed it:
sudo make uninstall
Or, manually delete all the corresponding files and folders (run whereis python3.13
to tell).
Hi Buddy! Thanks for the heads up, I can only suggest ‘alias py=python3.13’ (figure out the rest from there)