Skip to content

1. Getting started

Beginner · 6 min read

Everything in GenAI engineering — calling LLM APIs, building RAG pipelines, serving models — is done in Python. This page gets you from zero to running code.

1.1 Install Python

  1. Download the latest Python 3 installer from python.org/downloads.
  2. On the first screen tick "Add python.exe to PATH", then click Install Now.
  3. Open a new Command Prompt and check:
python --version

macOS may ship an old version. Install the current one from python.org/downloads (or brew install python), then check:

python3 --version

You should see Python 3.10 or newer.

1.2 Your first script

Create a file called hello.py:

hello.py
# A comment starts with "#" — Python ignores it.
name = "Priya"                      # store a value in a variable
print("Hello,", name)               # → Hello, Priya
print(f"{name} has {len(name)} letters")   # → Priya has 5 letters

Run it from the same folder:

python hello.py
python3 hello.py

1.3 The interactive shell (REPL)

Type python (or python3) with no file name to get a >>> prompt. Each line runs immediately — handy for trying things out. Type exit() to leave.

>>> 2 + 3
5
>>> "gen" + "ai"
'genai'

1.4 Virtual environments

A virtual environment is a private folder of packages for one project, so projects don't break each other's dependencies. Create one per project:

python -m venv .venv
.venv\Scripts\activate.bat
pip install requests
python3 -m venv .venv
source .venv/bin/activate
pip install requests

(.venv) appears in your prompt while it's active; deactivate leaves it. Save your dependencies so others can recreate them:

pip freeze > requirements.txt       # write installed packages
pip install -r requirements.txt     # install them elsewhere

1.5 Choosing an editor

VS Code with the Python extension is the most common choice: it shows errors as you type, runs files with one click, and lets you pick the .venv interpreter (bottom-right corner).

Why it matters for GenAI

LLM SDKs (openai, anthropic, langchain…) update often. A virtual environment per project plus a requirements.txt keeps each project's versions stable.

Practice

  • Install Python and print your version.
  • Create a project folder with a virtual environment and install requests.
  • Write hello.py that prints your name and how many characters it has.