ailiteracynepal 🇳🇵
Text size

Chapter 01 · Section II · 28 min read

Installing Python, an editor, and notebooks

The fiddly chapter. We install three pieces of equipment that turn a laptop into a place where you can build. Do it once carefully and the next four courses go smoothly.

Every craft has a workshop. A carpenter has a bench, chisels, and a place to keep wood dry. A tailor has a machine, a measuring tape, and a strong light to thread a needle by. Building AI is no different. Before you write a line of code, you set up three pieces of equipment — Python, an editor, and a notebook environment — and you set them up well, because doing this once carefully will save you a hundred frustrations later.

The three pieces, briefly

There are exactly three things to install. Most people new to this confuse them, so an early definition:

  1. Python is the language itself — a program on your computer that reads code you type and runs it.
  2. An editor is where you type code. We will use Visual Studio Code (VS Code), which is free and what almost everyone in this ecosystem uses.
  3. Jupyter notebooks are a way of running Python in small chunks, with output and prose interleaved — like a lab notebook. They are how you will spend most of your hours in Courses 01 through 04.

Treat the next thirty minutes as a one-time investment. When you are done, you will not touch these instructions again.

Installing Python

A small but important note before you start: install Python 3.12 or 3.11, not the absolute latest version. New Python releases sometimes outpace the libraries we will use, and “I installed the newest one” is the second most common reason a beginner’s setup breaks. (The first is the PATH issue on Windows — we will get to that.)

On macOS

The cleanest path is Homebrew. If you do not already have Homebrew, install it from brew.sh, then:

brew install python@3.12

Verify it worked:

python3 --version

You should see something like Python 3.12.x. If the version number starts with 3.12. or 3.11., you are done.

On Windows

Download the installer from python.org/downloads. When the installer opens, before clicking Install Now, look for a checkbox at the bottom of the first screen that says “Add python.exe to PATH”. Check it.

After installing, open PowerShell or Command Prompt and run:

python --version

(Note: on Windows it is usually python, not python3.)

On Linux

Most distributions already have Python 3. To check:

python3 --version

If you need to install or upgrade:

sudo apt update
sudo apt install python3.12 python3-pip

(Replace apt with your distribution’s package manager if you are not on Debian/Ubuntu.)

Installing VS Code

VS Code is a free editor from Microsoft. It is around 100 MB to download — comfortable on home wifi, slow on a typical Worldlink connection during the day, painful on mobile data. Plan accordingly.

  1. Download from code.visualstudio.com and install.
  2. Open it once it is installed.
  3. Open the Extensions panel (the four squares icon on the left, or Ctrl+Shift+X / Cmd+Shift+X).
  4. Search for and install two extensions, both published by Microsoft:
    • Python
    • Jupyter

Both extensions are free. Together they turn VS Code into a complete Python and notebook environment. You do not need to install anything else (no PyCharm, no Anaconda, no separate Jupyter server).

Your first notebook

A notebook is a file with the extension .ipynb (“interactive Python notebook”). It is a list of cells — each cell holds either some code or some prose. You run a code cell, see the result, then move to the next.

Try it now. In VS Code:

  1. Make a new folder somewhere on your laptop. Call it building-ai-notes or similar. Keep all your work for this track here.
  2. Open the folder in VS Code (File → Open Folder).
  3. Create a new file. Name it setup-check.ipynb. VS Code will recognise the extension and open it as a notebook.
  4. VS Code will prompt you to choose a kernel. Choose the Python 3.12 you installed earlier.
  5. In the first cell, type:
1 + 1
  1. Press Shift+Enter to run the cell.

If you see 2 appear below the cell, your workshop is built. Take a moment. That 2 is the first piece of evidence, in your own hands, that you are a person who can run code.

Try one more, to be sure:

import sys
print(sys.version)

You should see the Python version printed below the cell. If you do, everything is wired correctly.

When things go wrong

The first installation is the only one in this track where things genuinely break. Some recoveries:

python is not recognized” / “command not found”. Your terminal cannot find Python. On Windows, this almost always means PATH was not set during install — reinstall, check the box. On Mac or Linux, try python3 instead of python; both work, but the binary is usually named python3.

Two Python versions installed. This is fine. VS Code lets you choose which one to use per project — when it prompts you to pick a kernel for your notebook, choose the 3.12 one.

The notebook will not run a cell. Usually means the Python or Jupyter extension is not installed, or VS Code does not know which Python to use. Open the command palette (Ctrl+Shift+P / Cmd+Shift+P), type “Python: Select Interpreter”, and pick your 3.12.

Slow downloads, unstable connection. If your bandwidth is unreliable, do the downloads in a single session at home or at a wired connection point. Pulchowk and KU library wifi are reliable for most people. Some Itahari and Pokhara hub-spaces have mirrors as well.

The cyber café option. If you cannot install anything on your machine — shared family computer, work laptop locked down by IT, cyber café — you can do almost the entire track in a browser using Google Colab (colab.research.google.com). Colab gives you a free, pre-installed Python notebook environment with no setup at all. The only real cost is that you need a steady connection while working.

Check your understanding

Quick check

A friend in Birgunj has installed Python on her Windows laptop but every time she types `python` in PowerShell she sees the error `'python' is not recognized as an internal or external command`. What is by far the most likely cause?

Quick check

You are about to start Course 01 from a friend's cyber café in Pokhara. You cannot install Python or VS Code because the machine is locked down. Which option from this section would let you start the course anyway?

What comes next

You have a workshop. In the next section we use it for the first time: a small Python program, written in Devanagari, that we will take ten minutes to truly understand — line by line, character by character. By the end of it, you will have written, run, and read a complete program. Modest, but the first real thing.