Recent - Posts

Installing Python and setting up your environment (Windows, macOS, Linux) and Launching Your First Program.

You’re building something real and helpful, and this is the foundation: a clean Python install with a sane workflow so your projects are fast, reproducible, and headache-free. By the end, you’ll have Python installed, packages working, virtual environments set up, and VS Code ready to run and debug your code. We’ll keep it practical, cross‑platform, and beginner‑friendly—without cutting corners.

Why a clean setup matters

  • Consistency: A proper setup avoids the “works on my machine” curse. Virtual environments let you isolate dependencies per project.

  • Speed: You’ll install what you need—nothing bloated. Package managers and tools like Homebrew or apt make updates trivial.

  • Reproducibility: Pin dependencies via requirements.txt so others (and future you) can recreate your exact environment.

Installing Python on Windows

Option 1: Official Python installer (recommended)

  • Download: Go to python.org and get the latest stable Python 3.x for Windows.
  • Run the installer: Check the box “Add Python to PATH” at the bottom of the first screen.
  • Install Now: Default options are fine. This installs python, pip, and ILE.
  • Verify: Open Command Prompt and run:
python --version
pip --version
  • If python opens the Microsoft Store instead, use:
py --version

Installing Python on Windows

Option 1: Official Python installer (recommended)

  • Download: Go to python.org and get the latest stable Python 3.x for Windows.
  • Run the installer: Check the box “Add Python to PATH” at the bottom of the first screen.
  • Install Now: Default options are fine. This installs python, pip, and IDLE.
  • Verify: Open Command Prompt and run:
python --version
pip --version
  • If python opens the Microsoft Store instead, use:
py --version

Option 2: Windows Store (fast but less flexible)

  • Install “Python 3.x” from the Microsoft Store.
  • Use the py launcher (e.g. py -3.12) to select versions.

Installing Python on macOS

Option 1: Official Python installer

  • Download the macOS installer from python.org.
  • Verify installation:
python3 --version
pip3 --version

Option 2: Homebrew (developer-friendly)

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install python
python3 --version
pip3 --version

Installing Python on Linux

Ubuntu/Debian

sudo apt update
sudo apt install -y python3 python3-pip python3-venv
python3 --version
pip3 --version

Fedora

sudo dnf install -y python3 python3-pip python3-virtualenv
python3 --version
pip3 --version

Arch

sudo pacman -Syu python python-pip
python --version
pip --version

Setting up Virtual Environments

Using venv (built-in)

python3 -m venv .venv
source .venv/bin/activate   # macOS/Linux
.venv\Scripts\activate      # Windows
pip install requests numpy
pip freeze > requirements.txt
deactivate

Using pipx (for global CLI tools)

python3 -m pip install --user pipx
pipx install black
pipx install flake8

Using conda (data science workflows)

conda create -n myenv python=3.12
conda activate myenv

Installing Essential Packages

pip install requests beautifulsoup4
pip install numpy pandas matplotlib
pip install scikit-learn opencv-python
For your Intruder Detection project:
pip install scikit-image scikit-learn opencv-python imutils

Setting up VS Code

Your first Python script

def greet():
    print("Hello, Bits, Boots & Beyond!")
Run it in terminal:
python hello.py

  • Or VS Code “Run Python File” 

Debugging:

  • Open hello.py → Run and Debug → “Python file”.
  • VS Code generates a launch.json for breakpoints, env vars, args, etc.

Common pitfalls and quick fixes

  • D"pip not found”: Use python -m pip install to guarantee the right pip.
  • Permission denied on macOS: Allow the installer in System Settings → Privacy & Security if blocked.
  • SSL errors when installing packages: Update pip and certifi, or check corporate proxy settings
  • Windows PowerShell execution policy: If activation is blocked:





Project structure that scales

your_project/
├─ .venv/
├─ src/
│└─ main.py
├─ tests/
├─ requirements.txt
└─ README.md

  • Keep secrets out of code. Use .env and python-dotenv for local configs

What’s next (Class 3 preview)

  • Configure VS Code like a pro: format on save, linting, testing.
  • Build a tiny CLI tool.
  • Start “Intruder detection” groundwork: HoG features, simple SVM classifier on a small dataset

    Comments