02. Your Environment
What You Need
For this course, you need:
- Python 3.12 or newer
- A text editor (VS Code, Neovim, Zed, anything that saves plain text)
- A terminal (bash, zsh, PowerShell)
That is it. Do not install JupyterLab, Docker, or anything else yet. You need to understand plain Python first.
Installing Python
macOS and Linux
Your system likely has Python 3 already. Check:
python3 --version
If you see 3.12.x or higher, you are set. If not, use a package manager:
# macOS with Homebrew
brew install [email protected]
# Ubuntu/Debian
sudo apt update
sudo apt install python3.12
Windows
Download the installer from python.org/downloads. During installation, check "Add Python to PATH". Open Command Prompt or PowerShell and verify:
python --version
Your First Script
Create a file called hello.py:
print("Hello, AI")
Run it:
python3 hello.py
If you see "Hello, AI", your environment works.
Virtual Environments (Why They Matter)
Every project needs its own environment. This prevents version conflicts between projects.
# Create a virtual environment
python3 -m venv myproject
# Activate it
# macOS/Linux:
source myproject/bin/activate
# Windows:
myproject\Scripts\activate
# Now install packages only for this project
pip install numpy
When activated, your terminal shows (myproject) prefix. Packages you install go into this isolated environment.
Installing NumPy and Pandas
For chapters 10 onward, you need NumPy and Pandas:
pip install numpy pandas requests
Verify installation:
import numpy as np
import pandas as pd
print(f"NumPy {np.__version__}, Pandas {pd.__version__}")
- Create a directory for this course
- Create a virtual environment inside it
- Activate it
- Run
pip install numpy pandas requests - Create a test script that imports all three and prints their versions