~/TechPurAI
~/tutorials/python-from-scratch/installing-python-and-your-first-script
beginner·part 1 of 6·3 min read

Installing Python and your first script

Updated Aug 11, 2026Python

By the end of this series you'll have a command-line expense tracker that stores real data on disk and runs like any other terminal tool. This first part gets Python running and puts a file on disk you can execute — nothing else, so that any error you hit later comes from your code rather than your setup.

Check what you already have

macOS and most Linux distributions ship with Python. Windows usually doesn't. Check before installing anything:

bash
python3 --version

On Windows, try python --version instead. If you get 3.10 or newer, you're set. Anything older — or a command not found — means installing from python.org/downloads, where the installer handles the details for your platform.

Windows only

On the Windows installer's first screen, tick Add python.exe to PATH before clicking Install. Without it, python won't be recognized in a new terminal and you'll be editing environment variables by hand later.

Create the project

Make a folder for the tracker and move into it:

bash
mkdir expense-tracker
cd expense-tracker

Every command from here on assumes you're inside this folder.

Create a virtual environment

A virtual environment is a private copy of Python for one project. Packages you install go into it instead of your system Python, so two projects can use different versions of the same library without a conflict:

bash
python3 -m venv .venv

That creates a .venv folder. Creating it isn't enough — you have to activate it in each new terminal session:

bash
source .venv/bin/activate

On Windows PowerShell, the activate script lives elsewhere:

powershell
.venv\Scripts\Activate.ps1

Your prompt now starts with (.venv). That prefix is the whole point: it tells you which Python will run when you type python. When it's missing, you're back on the system one.

Your first script

Create a file named tracker.py with two lines:

python
print("Expense tracker")
print("No expenses yet.")

Run it:

bash
python tracker.py

Both lines appear in the terminal. print() writes its argument to standard output and adds a newline — it's how a script talks back to you, and it's the tool you'll use most while learning, because it shows you what a value actually contains instead of what you assume it contains.

Checkpoint

If you see python: command not found while (.venv) is in your prompt, the environment was created by a different Python than the one on your PATH. Delete the .venv folder, re-run the venv command with the exact interpreter that answered --version above, and activate it again.

Why a .py file instead of the REPL

Typing python with no arguments opens an interactive prompt where you can run one line at a time. It's useful for checking what a function does, but everything vanishes when you close it. A .py file is a program you can re-run, edit, and eventually hand to someone else — which is what you want for anything you'll use more than once.

Next up: reading input from whoever is running the script, and the type conversion that trips up nearly everyone the first time.

VK

Vijay Kumar

Founder of TechPurAI — writing hands-on tutorials and honest tool breakdowns.

LinkedIn ↗
next →2. Variables, types, and reading input