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.

Now extract & build.
build_python.sh
tar xvf Python-3.13.0.tar.xz
cd Python-3.13.0
./configure --enable-optimizations --prefix=$HOME/usr
make -j$(nproc) installThis 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:
example.sh
export PATH=$HOME/usr/bin:$PATH
export PYTHON_ROOT=~/usr
export PYTHON_VERSION=3.13
export LD_LIBRARY_PATH=~/usr/lib:$LD_LIBRARY_PATHRemember to replace 3.13 with the actual version you installed.
and then run source ~/.bashrc or source ~/.zshrc.
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow