Module 0: Environment Setup

Professional Python setup using Pyenv, Virtual Environments, and VS Code.

🚀 The "Senior" Way

Beginners install Python directly from python.org. Seniors use version managers to handle multiple projects with different Python versions (e.g., 3.8 for legacy, 3.12 for new apps) without conflicts.

1. Install a Version Manager (Pyenv)

Never use the system Python. We will use pyenv to manage versions.

macOS (Homebrew):

brew update
brew install pyenv

# Add to your shell (zsh)
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo '[[ -d $PYENV_ROOT/bin ]] && export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(pyenv init -)"' >> ~/.zshrc

# Restart shell
exec "$SHELL"

Windows (PowerShell):

We recommend using pyenv-win.

Invoke-WebRequest -UseBasicParsing -Uri "https://raw.githubusercontent.com/pyenv-win/pyenv-win/master/pyenv-win/install-pyenv-win.ps1" -OutFile "./install-pyenv-win.ps1"; &"./install-pyenv-win.ps1"

2. Install Python & Create Project

# Install a specific version
pyenv install 3.11.5

# Set it as global default (optional)
pyenv global 3.11.5

# Create a project folder
mkdir my-python-project
cd my-python-project

# Set local version for this folder
pyenv local 3.11.5

3. Virtual Environments

Always isolate dependencies. We'll use the built-in venv module.

# Create virtual environment named '.venv'
python -m venv .venv

# Activate it
# macOS/Linux:
source .venv/bin/activate

# Windows:
.venv\Scripts\Activate

You should see (.venv) in your terminal prompt.

4. VS Code Setup

  1. Install the Python extension (Microsoft).
  2. Open your project folder in VS Code.
  3. Open the Command Palette (Cmd+Shift+P / Ctrl+Shift+P).
  4. Type "Python: Select Interpreter".
  5. Select the one marked ('.venv': venv).

Now VS Code will use your isolated environment for autocomplete and running code.

Next: Module 1 - Advanced Python →