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¶
- Download the latest Python 3 installer from python.org/downloads.
- On the first screen tick "Add python.exe to PATH", then click Install Now.
- Open a new Command Prompt and check:
macOS may ship an old version. Install the current one from
python.org/downloads (or brew install python), then check:
You should see Python 3.10 or newer.
1.2 Your first script¶
Create a file called 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:
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.
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:
(.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.pythat prints your name and how many characters it has.