python3.12 -m venv myproject_env source myproject_env/bin/activate This gives you the new Python version without touching the OS. If you need a very recent version not in deadsnakes:
Updating Python on Ubuntu is safe if you add new versions and leave the system Python untouched. The deadsnakes PPA is the best balance of convenience and safety. update python ubuntu
Would you like a step-by-step guide for a specific Ubuntu version (e.g., 20.04, 22.04, 24.04)? python3
sudo apt install build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev wget https://www.python.org/ftp/python/3.13.0/Python-3.13.0.tgz tar -xf Python-3.13.0.tgz cd Python-3.13.0 ./configure --enable-optimizations --prefix=/usr/local make -j $(nproc) sudo make altinstall # Never use `install` (would override system python3) Use as python3.13 , not python3 . | Goal | Method | |------|--------| | Just need newer Python for development | deadsnakes PPA + virtual environments | | Need to update the global python3 for all users | Not recommended; use update-alternatives carefully | | Isolated project with specific Python version | Docker, pyenv , or virtual environments | | Building from source for latest features | make altinstall + explicit versioned binary | Would you like a step-by-step guide for a