Python Setup
A well-configured Python environment uses virtual environments to isolate each project's dependencies. Getting this right from the start prevents version conflicts and 'works on my machine' problems.
Installing Python
Download Python 3.11 or newer from python.org. On Windows, tick Add Python to PATH during installation — without this, you cannot run python from the terminal. On macOS, use Homebrew: brew install python3. On Linux (Ubuntu/Debian): sudo apt install python3 python3-pip.
python --version
# or on some systems:
python3 --version
pip --version
Virtual Environments
A virtual environment is an isolated Python installation for a single project. Each project gets its own copy of packages without interfering with others. Always use a virtual environment — this is professional standard practice.
# Create a virtual environment in the current directory:
python -m venv venv
# Activate it:
# Windows:
venv\Scripts\activate
# macOS/Linux:
source venv/bin/activate
# Your prompt changes to (venv) when active
# Install packages inside it:
pip install requests pandas numpy
# Freeze your dependencies:
pip freeze > requirements.txt
# Recreate on another machine:
pip install -r requirements.txt
# Deactivate:
deactivate
Choosing an Editor
- VS Code + Python extension (free) — excellent debugger, IntelliSense, Jupyter support.
- PyCharm Community Edition (free) — the most full-featured Python IDE; built-in test runner.
- Jupyter Notebook — for data exploration and analysis; run code cells interactively.
# Run a Python script:
python script.py
# Or from VS Code:
# Right-click → Run Python File in Terminal
# Run a single expression (useful for quick tests):
python -c "print(2 + 2)"
Practice Task
Your Turn
Install Python 3.11+, verify with python --version. Create a project folder, create a virtual environment called fmtali-env, activate it, and install requests. Verify it installed with pip list. Write a simple script, run it, then deactivate the environment.
Common Mistakes
- Not activating the virtual environment before running pip — packages install globally instead of per-project.
- Python 2 is unsupported — never use it for new code.
- Committing the venv folder to Git — add
venv/to.gitignore. Commitrequirements.txtinstead. - Different command on different systems — some use
python3, otherspython. Know which yours uses.
Professional Tip
The requirements.txt pattern is how Python projects share their dependencies. When you join a team, the first thing you do is create a virtual environment and run pip install -r requirements.txt.
Mini Quiz
Why use a virtual environment for each Python project?