Python Installation and Environment Setup
Table of Contents
Method 1 – VS Code + Homebrew + uv #
Best for general Python, web development, and small projects. Lightweight, fast, and modern.
Installation #
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 --versionPython:
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- Installed as:
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 initThis automatically:
- Creates
pyproject.tomlif missing. - Creates or reuses a virtual environment (
.venv).- If
.venvexists, uses its Python interpreter. - Otherwise, creates one using the default
python3from PATH.
- If
- Optionally generates
uv.lock. - Detects existing dependencies.
- Creates
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 #
- Miniconda: Download & Install
Environment Setup #
Step 1 - Create a Python project environment and install dependencies:
conda env create -f environment.yamlExample
environment.yaml: View ExampleStep 2 - Create a Python Jupyter environment for running JupyterLab:
conda create -n jupyter_env python=3.14 jupyterlab -c conda-forgeStep 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 deactivatenb_conda_kernelsallows 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 python3Show the default Python / Python3 in use:
which python python3Run Python scripts (with
uv):uv run python <script-name>.pyOpen JupyterLab:
conda activate jupyter_env jupyter lab conda deactivateList all available Jupyter kernels:
conda activate jupyter_env jupyter kernelspec list conda deactivateRemove a specific Jupyter kernel:
conda activate jupyter_env jupyter kernelspec remove <kernel-name> conda deactivateList all Conda environments:
conda env listRemove a Conda environment:
conda env remove -n <env-name> conda clean --allSearch from the current directory downward and delete all
.DS_Storefiles (with confirmation):find . -name '.DS_Store' -type f -exec rm -i {} \;