Programming languages · Beginner · 12 min
How to Install Python 3.15 and Run Your First Script
By Padding · Updated 15 Nov 2026
Python 3.15 · uv 0.13
You will install uv 0.13 from a checksum-verified release on Ubuntu 26.04, use it to install Python 3.15 next to the system Python, and write and run your first script.
On this page
Ubuntu 26.04 comes with its own Python, which the operating system's tools depend on. Do not replace it or change what python3 points to. Instead, install a separate Python 3.15 that belongs to you and leave the system copy alone.
The tool for this is uv, a fast Python package and version manager from Astral. One small program downloads Python builds, creates virtual environments and installs packages, so you learn it once and use it for the rest of this series. In this tutorial you install uv, install Python 3.15 with it, and run a script. The next tutorial, virtual environments and packages in Python, builds on this setup.
There are other ways to get Python 3.15 on Ubuntu 26.04. The deadsnakes PPA publishes it as apt packages for 26.04, which suits you if you want apt to manage updates, and building from source works too. This tutorial uses uv because the same tool then handles the rest of the series, and it needs no root access to install Python itself.
Step 1 · Install uv
This step downloads the uv release archive from GitHub and checks it against the SHA-256 file that the release publishes before installing anything. A file you unpack yourself gets no apt updates. To upgrade later, repeat this step with a newer version number.
Install curl, pick the build for your processor, and download both files into a fresh temporary folder:
sudo apt update
sudo apt install -y curl ca-certificates
VERSION=0.13.8
case "$(uname -m)" in
x86_64) TARGET=x86_64-unknown-linux-gnu ;;
aarch64) TARGET=aarch64-unknown-linux-gnu ;;
*) echo "Unsupported processor: $(uname -m)"; false ;;
esac
cd "$(mktemp -d)"
curl -fsSLO "https://github.com/astral-sh/uv/releases/download/${VERSION}/uv-${TARGET}.tar.gz"
curl -fsSLO "https://github.com/astral-sh/uv/releases/download/${VERSION}/uv-${TARGET}.tar.gz.sha256"
sha256sum -c "uv-${TARGET}.tar.gz.sha256"If the first command printed Unsupported processor, stop here. The last command must print uv-<target>.tar.gz: OK. If it prints FAILED, stop, delete the files and download again. Then unpack the archive and put the two programs in ~/.local/bin, a folder in your home directory:
tar -xzf "uv-${TARGET}.tar.gz"
mkdir -p ~/.local/bin
install -m 0755 "uv-${TARGET}/uv" "uv-${TARGET}/uvx" ~/.local/bin/
export PATH="$HOME/.local/bin:$PATH"
uv --versionUbuntu adds ~/.local/bin to your path when you log in, if the folder exists. The export line makes it work in the current shell right away.
Check it worked
uv --version prints uv 0.13.8 and your platform, such as (x86_64-unknown-linux-gnu).
Troubleshooting
If you get uv: command not found in a later shell, log out and back in, or run the export PATH=... line again. If curl fails with a 404, check that VERSION is a real release on the uv releases page.
Step 2 · Install Python 3.15
Ask uv for Python 3.15. It downloads a prebuilt interpreter, so it takes seconds and compiles nothing:
uv python install 3.15uv installs it under ~/.local/share/uv/python/ and links python3.15 into ~/.local/bin. The system Python is not touched. List what uv manages:
uv python list --only-installed
python3.15 --versionCheck it worked
python3.15 --version prints Python 3.15. followed by a patch number. The list shows a cpython-3.15. entry at a path in your home directory. Your system python3, if it is installed, still reports its own version.
Step 3 · Write your first script
Make a project folder and a script. The script takes an optional name from the command line, and prints a greeting, the name's length and the Python version that ran it:
mkdir -p ~/first-script
cd ~/first-script
cat > greet.py <<'PY'
import sys
name = sys.argv[1] if len(sys.argv) > 1 else "world"
version = ".".join(str(part) for part in sys.version_info[:3])
print(f"Hello, {name}!")
print(f"Your name has {len(name)} letters.")
print(f"Running on Python {version}")
PYA few things happen here. import sys loads a module from the standard library. sys.argv is the list of command-line words, and its first item is the script's own name, so the first argument you type is item 1. The f"..." strings fill in values written inside the curly braces.
Step 4 · Run it
Run the script with Python 3.15, once without an argument and once with one:
python3.15 greet.py
python3.15 greet.py AdaCheck it worked
The first run prints Hello, world!, Your name has 5 letters. and a line that starts Running on Python 3.15.. The second prints Hello, Ada! and Your name has 3 letters.
Troubleshooting
python3.15: command not found means ~/.local/bin is not on your path in this shell. Run export PATH="$HOME/.local/bin:$PATH". A SyntaxError points at a line and column in the file. Check for a missing quote or a stray space at the start of a line, since Python uses indentation as part of its syntax.
Step 5 · Pin the version for the project
Another person, or you in a year, may have a different Python first on the path. Record the version the project needs in a file, and let uv honour it:
uv python pin 3.15
cat .python-version
uv run greet.py Graceuv python pin writes .python-version containing 3.15. uv run reads that file, finds or downloads a matching Python, and runs the script with it. Commit .python-version with your code. It also works with other tools that read the same file, such as pyenv.
Check it worked
cat prints 3.15, and the uv run command prints Hello, Grace! with a line that starts Running on Python 3.15.
Step 6 · Update and remove Python
Python 3.15 gets patch releases. To move to the newest one in the 3.15 line, run:
uv python upgrade 3.15To remove an interpreter you no longer use, or to undo this tutorial:
uv python uninstall 3.15
rm -rf ~/first-scriptThe first command removes the interpreter and its link in ~/.local/bin. To remove uv itself, delete ~/.local/bin/uv and ~/.local/bin/uvx, and delete uv's data and cache folders; uv cache dir and uv python dir print where they are. Run uv python uninstall first, because it needs uv to find them.
Next steps
- Keep project libraries apart from each other: virtual environments and packages in Python.
- Learn to save and load data: read and write files and JSON.
- The uv documentation at docs.astral.sh/uv covers the commands used here in more detail.
Related tutorials
- How to Write and Run Your First Web Server in GoYou will write a web server in Go 1.27 using only the standard library, with path routes, a JSON endpoint, a POST handler, timeouts and a clean shutdown, then test the handlers without opening a port and build the server into one binary.
- How to Write and Run Tests in Python with pytestYou will install pytest 9.2 in a uv project, write tests for a small price-parsing module, run many cases from one test with parametrize, read a failure and fix the code, and use a fixture that gives each test its own temporary folder.
- How to Set Up a TypeScript 7 Project from ScratchYou will create a Node.js 26 project, install TypeScript 7, write a tsconfig.json you understand, compile two files to JavaScript, watch the compiler catch a type error, and add npm scripts for building, checking and running.
Need this done for you?
Padding does this work for growing companies, from the first diagnosis to a system that keeps working.
Get new tutorials