← Getting Started Lesson 1 of 3

Setting up: Python, VS Code and Jupyter

Why install anything?

In these pages, Python runs inside your browser, so you can start straight away. Real work happens on your own computer, because there:

  • your files stay, in folders you choose;
  • you can open big data files, many megabytes long;
  • you can install any of the thousands of free Python tools.

You need three things: Python itself, VS Code (an editor to write code in), and Jupyter (notebooks, where code and results sit together). All three are free.

Keep using these pages to learn. Install the tools today so they're ready when your projects start.

First, Python.

Installing Python

  1. Go to python.org, open Downloads, and download the latest Python 3 for your computer.
  2. Windows: run the installer and tick "Add python.exe to PATH" on its first screen, then press Install Now.
    Mac: open the downloaded file and follow the steps.
  3. Check it worked: open a terminal (Windows: search "Command Prompt"; Mac: search "Terminal") and type python --version. On a Mac, type python3 --version.

If it prints a version, like Python 3.14.0, Python is ready.

Try it in this pretend terminal: type python --version and press Enter.

Python is installed. Now we need somewhere comfortable to write code.

VS Code: an editor for code

You could write Python in Notepad, but an editor made for code colours it, spots mistakes and runs it for you. We use VS Code.

  1. Download it from code.visualstudio.com and install it.
  2. Open it, click the Extensions icon (four squares) on the left, search Python, and install the one by Microsoft.
  3. Make a folder for your work, like data-course, and open it: File → Open Folder.
  4. New file: hello.py. Type print("Hello!"), save, and press the ▶ button at the top right.

The answer appears in the terminal panel at the bottom: VS Code ran python hello.py for you.

Let's do exactly that by hand.

Running a Python file

A file that ends in .py holds Python code. The command python hello.py tells Python: "run every line of this file, from the top".

Below, echo … > hello.py writes a line into a new file (you'll learn this in the next lesson), and cat hello.py shows what's in it.

Try it: type these three commands, one at a time, pressing Enter after each.
echo 'print("Hello from a file!")' > hello.py
cat hello.py
python hello.py

Press ↑ in the terminal to bring back the last command, instead of typing it again.

Python comes with the basics. Data tools like pandas must be added.

Packages and pip

A package is a set of ready-made Python tools that someone wrote and shared. pandas (for tables) and Matplotlib (for charts) are packages.

pip is the program that downloads and installs packages: pip install pandas. pip list shows what's installed.

Try it: type pip install pandas, then pip list. Read the note pip prints at the end.

That note warns about a problem. Here's how to avoid it.

Virtual environments

If every project installs into the same Python, two projects that need different versions of a package will clash. So each project gets its own private set of packages, called a virtual environment.

  1. python -m venv .venv makes one, in a folder called .venv.
  2. source .venv/bin/activate switches it on (on Windows: .venv\Scripts\activate). The prompt starts with (.venv).
  3. Now pip install puts packages in this project only. deactivate switches it off.
Try it: make the environment, switch it on, and install pandas. Watch the prompt change.

Files are great for programs. For exploring data, there's something better.

Jupyter notebooks

A notebook is a file (ending in .ipynb) made of cells. Each cell holds a little code; you run one cell at a time, and its result appears right under it. Earlier cells' variables stay, so the next cell can use them.

That's ideal for data: load the data in one cell, look at it, then try the next step in the next cell. In VS Code: install the Jupyter extension, make a file explore.ipynb, and press Shift + Enter to run a cell.

These two boxes work like two cells. Run the first, then the second: it uses prices from the first.

Run the second box first and you get an error: prices doesn't exist yet. Notebooks have the same rule: run the cells in order.

Time to set up a project in the terminal on your own.

Practice 1.1: a new project

Remember: mkdir name makes a folder, cd name goes into it, python -m venv .venv makes an environment.

Set up a project folder the way you would on your own computer. The list ticks itself as you go.

Ready? A short test on this lesson.

Lesson 1 test

Think first, then pick. A wrong answer shows which page to read again.

1. InstallingOn Windows, which box must you tick in the Python installer?
2. RunningHow do you run the file report.py from the terminal?
3. PackagesYou need the package seaborn on your computer. What do you type?
4. EnvironmentsWhy give each project a virtual environment?
5. NotebooksCell 1 makes prices; cell 2 prints max(prices). You open the notebook and run only cell 2. What happens?

What's next?

This leaves a question
We typed commands like cd and mkdir. What are they, and what else can the terminal do?
Lesson 2 answers it.