Skip to main content

Python Installation and Environment Setup

Method 1 – VS Code + Homebrew + uv #

Best for general Python, web development, and small projects. Lightweight, fast, and modern.

Installation #

  • VS Code: Download & Install

  • Homebrew: Install

    Then add Homebrew to your PATH:

    echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> /Users/<user-name>/.zprofile
    eval "$(/opt/homebrew/bin/brew shellenv)"
    
    • Ensure Homebrew is available in new terminal sessions
    • Apply Homebrew settings immediately without restarting the terminal

    (Optional) Verify installation

    brew --version
    
  • Python:

    brew install python@3.13
    brew cleanup python@3.13
    
    • Installed as: /opt/homebrew/bin/python3
    • Remove outdated files (does NOT uninstall Python)

    (Optional) Verify installation

    python3 --version
    
  • uv (a fast Python package and environment manager):

    curl -LsSf https://astral.sh/uv/install.sh | sh
    

Environment Setup #

  • Step 1 - Create a Python Project Environment:

    uv init
    

    This automatically:

    • Creates pyproject.toml if missing.
    • Creates or reuses a virtual environment (.venv).
      • If .venv exists, uses its Python interpreter.
      • Otherwise, creates one using the default python3 from PATH.
    • Optionally generates uv.lock.
    • Detects existing dependencies.
  • Step 2 - Install dependencies:

    uv add regex torch torchvision PyYAML matplotlib requests tqdm notebook
    

Method 2 – Conda #

Best for data science, machine learning, and scientific computing. Heavier, but handles complex libraries well.

Installation #

Environment Setup #

  • Step 1 - Create a Python project environment and install dependencies:

    conda env create -f environment.yaml
    

    Example environment.yaml: View Example

  • Step 2 - Create a Python Jupyter environment for running JupyterLab:

    conda create -n jupyter_env python=3.14 jupyterlab -c conda-forge
    
  • Step 3a (recommended; choose either 3a or 3b) - Enable automatic Jupyter kernel discovery:

    conda activate jupyter_env
    conda install nb_conda_kernels -c conda-forge
    conda deactivate
    

    nb_conda_kernels allows JupyterLab to automatically detect all Conda environments as usable kernels.

  • Step 3b (choose either 3a or 3b) - Configure a Jupyter kernel manually:

    conda activate <env-name>
    conda install ipykernel -c anaconda
    ipython kernel install --user --name=<kernel-name>
    conda deactivate
    

Extra Useful Commands #

  • List all Python / Python3 executables in PATH:

    which -a python python3
    
  • Show the default Python / Python3 in use:

    which python python3
    
  • Run Python scripts (with uv):

    uv run python <script-name>.py
    
  • Open JupyterLab:

    conda activate jupyter_env
    jupyter lab
    conda deactivate
    
  • List all available Jupyter kernels:

    conda activate jupyter_env
    jupyter kernelspec list
    conda deactivate
    
  • Remove a specific Jupyter kernel:

    conda activate jupyter_env
    jupyter kernelspec remove <kernel-name>
    conda deactivate
    
  • List all Conda environments:

    conda env list
    
  • Remove a Conda environment:

    conda env remove -n <env-name>
    conda clean --all
    
  • Search from the current directory downward and delete all .DS_Store files (with confirmation):

    find . -name '.DS_Store' -type f -exec rm -i {} \;