Skip to content

Python on Your Own Machine

The Course
•
January 9, 2026
•
5 min read

This lesson is optional. Nothing else in the course needs it: every exercise runs on this site. Do it when you want a Python that can reach the network, read your real files, and install other people's libraries. There is nothing to run on the page; the commands below go in a terminal on your own computer.

You're done when a file you wrote prints Hello from my computer in your terminal, inside a virtual environment. The checklist at the end walks you there.

Opening a terminal

A terminal is a window where you type commands instead of clicking.

  • Windows: press the Windows key, type PowerShell, press Enter.
  • macOS: press Cmd-Space, type Terminal, press Enter.
  • Linux: press Ctrl-Alt-T, or find Terminal in your applications.

The terminal always works in one folder. Make a folder for your practice and move into it:

Shell
mkdir python-practice
cd python-practice

mkdir makes a folder; cd ("change directory") moves into it. Every command below assumes you're in this folder. cd .. goes back up one level.

Getting Python

Check whether you already have it. macOS and most Linux distributions ship a Python, though sometimes an old one:

Shell
python3 --version

If that prints Python 3.11 or newer, you are set. Otherwise:

  • Windows — install from the Microsoft Store, or python.org. Tick "Add Python to PATH" in the installer.
  • macOS — brew install python if you use Homebrew, otherwise the python.org installer.
  • Linux — sudo apt install python3 python3-venv python3-pip on Debian/Ubuntu.
python or python3?

On Windows the command is usually python. On macOS and Linux, python3 is the safe one — plain python may be missing or point at an ancient Python 2.

Running a file

Open a text editor (see An editor below, or Notepad/TextEdit for now), type one line, and save it as hello.py inside python-practice:

Python
print("Hello from my computer")

Then run it from the terminal:

Shell
python3 hello.py

On Windows, type python hello.py instead.

can't open file 'hello.py' means the terminal is in a different folder than the file: check with ls (macOS/Linux) or dir (Windows), and cd to the folder that holds it.

Running python3 with no file gives you the REPL — an interactive prompt where each line runs as you press Enter. It is the closest thing to the playgrounds on this site, and it is where experienced Python programmers test small ideas. exit() or Ctrl-D leaves it.

Virtual environments

A virtual environment is a private folder of packages belonging to one project. Without one, every pip install goes into your system Python, and two projects that need different versions of the same library cannot both work.

Make one per project, in the project folder:

Shell
python3 -m venv .venv

Then activate it:

Shell
source .venv/bin/activate

On Windows PowerShell, that line is .venv\Scripts\Activate.ps1 instead. The first time, PowerShell may refuse with running scripts is disabled on this system. Allow scripts you created yourself, for your account only, with:

Shell
Set-ExecutionPolicy -Scope CurrentUser RemoteSigned

Answer Y, then run the activate line again. Your prompt gains a (.venv) prefix, and python now means this project's Python. deactivate leaves it.

Don't copy or share .venv

The folder is large, belongs to one machine, and rebuilds in seconds. Share your code and a requirements.txt (below), never the .venv folder. If you use git for version control, list .venv/ in a file named .gitignore so it is never saved.

Installing packages

With the environment active, pip installs from the Python Package Index:

Shell
pip install requests

Record what a project needs so someone else — or you, on another machine — can reproduce it:

Shell
pip freeze > requirements.txt

And install from that record:

Shell
pip install -r requirements.txt

Three packages worth knowing about early:

PackageWhat it does
requestsHTTP the pleasant way
pytestThe testing tool almost everyone uses (Day 7)
ruffFast linter and formatter — catches mistakes before you run

An editor

Any text editor works, but a real Python editor will show you errors as you type. VS Code with the Python extension is the common choice and free; PyCharm is the heavyweight alternative.

Point your editor at the interpreter inside .venv so it sees the same packages your program will.

A sensible project layout

Text
myproject/
├── .venv/               # virtual environment, not committed
├── .gitignore
├── requirements.txt
├── README.md
├── src/
│   └── myproject/
│       ├── __init__.py
│       └── main.py
└── tests/
    └── test_main.py

You do not need all of this for a fifty-line script — but when a script grows into a program, this is the shape it grows into. Day 7 builds a small version.

Checklist

Tick these off in order. If one fails, the step above it tells you why.

  1. python3 --version (or python --version on Windows) prints 3.11 or newer.
  2. cd python-practice works, and hello.py is listed by ls or dir.
  3. python3 hello.py (or python hello.py on Windows) prints Hello from my computer.
  4. After python3 -m venv .venv and the activate line, your prompt starts with (.venv).
  5. With (.venv) showing, python hello.py still prints the greeting.

What you learned

  • python3 --version checks what you have; python3 file.py runs a program.
  • python3 alone opens the REPL for quick experiments.
  • python3 -m venv .venv plus source .venv/bin/activate isolates a project.
  • pip install adds packages; pip freeze > requirements.txt records them.
  • Keep .venv/ out of version control.
Last updated on January 9, 2026

Was this article helpful?

Your response is saved on this device.