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 - Enable automatic Jupyter kernel discovery:
Create a environment for running JupyterLab (This step is done once only):
conda create -n jupyter_env python=3.10 jupyterlab -c conda-forgeIn case to open Jupyter Lab:
conda activate jupyter_env jupyter lab conda deactivateInstall kernel discovery tool
nb_conda_kernels, which allows JupyterLab to automatically detect all Conda environments as usable kernels (This step is done once only):conda activate jupyter_env conda install nb_conda_kernels -c conda-forge conda deactivateInstall kernel support in each environment:
conda activate <env-name> conda install ipykernel -c anaconda conda deactivateAlternatively, configure a Jupyter kernel manually (This step is optional):
conda activate <env-name> ipython kernel install --user --name=<kernel-name> conda deactivateIn case running this optional:
List 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 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>.pyList all Conda environments and remove a Conda environment:
conda env list 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 {} \;