pyenv – it's safe, flexible, and doesn't require root.

export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" Restart your shell. # List available Python versions pyenv install --list Install a specific version pyenv install 3.12.2 Set global (user-wide) Python version pyenv global 3.12.2 Set local (project-specific) version pyenv local 3.12.2 Verify python --version

conda install python=3.12 # Or create a new environment conda create -n py312 python=3.12 conda activate py312 After upgrading, ensure pip is updated for the new Python version: