How to build & install Python 3.13 without sudo

First, download Python 3.13.0. You can also select another version from the main download page.

Scroll down on the page. I recommend to select the XZ compressed source tarball.

Python Download XZ compressed source tarball

Now extract & build.

tar xvf Python-3.13.0.tar.xz
cd Python-3.13.0
./configure --prefix=$HOME/usr
make -j$(nproc) install

This will install to $HOME/usr. You can change this to any other location you prefer. When using $HOME/usr, the headers will be installed in ~/usr/include and the libraries in ~/usr/lib etc.

In order to use Python from ~/usr, you need to add the following to your .bashrc or .zshrc:

export PATH=$HOME/usr/bin:$PATH
export PYTHON_ROOT=~/usr
export PYTHON_VERSION=3.13
export LD_LIBRARY_PATH=~/usr/lib:$LD_LIBRARY_PATH

Remember to replace 3.13 with the actual version you installed.

and then run source ~/.bashrc or source ~/.zshrc.