This simple tutorial shows how to install Python 3.13, which is still in development stage, in Ubuntu 22.04, or Ubuntu 20.04 LTS.
Python 3.13 so far is in alpha development stage. For testing or software developing purpose, you can install it in Ubuntu either from PPA or by building from source tarball.
Features in Python 3.13 so far, compare to the last 3.12:
- exception tracebacks now colorized by default in the interactive interpreter.
- Docstrings now have their leading indentation stripped , reducing memory use and the size of .pyc files.
- 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.
- Many other removals of deprecated classes, functions and methods in various standard library modules.
- New deprecations, most of which are scheduled for removal from Python 3.15 or 3.16.
- C API removals and deprecations.
Option 1: Install Python 3.13 from Ubuntu PPA
The popular deadsnakes PPA has built the latest Python 3.13 alpha for current 2 Ubuntu LTS releases.
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
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.0a3.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).