Skip to content

Latest commit

 

History

History
327 lines (220 loc) · 6.65 KB

MAC_SETUP.md

File metadata and controls

327 lines (220 loc) · 6.65 KB

Set Up Your Mac for Data & Development Work

This guide will help you set up your Mac for Python, data science and development work using modern tools.


1. Keep macOS Up-to-Date

Keeping your system updated ensures security and compatibility.

  1. Open System SettingsGeneralSoftware Update
  2. Install any available updates.
  3. Enable "Automatically keep my Mac up to date"
  4. Update apps via the App Store (Open App Store → Click Updates)

2. Open the Terminal

The Terminal is your command-line interface. Open it by pressing Cmd + Space and searching for "Terminal".

If you prefer, install iTerm2 for a more feature-rich terminal.


3. Install Xcode Command Line Tools

Xcode Command Line Tools are required for compiling packages, running Git, and using Homebrew.

Installation Steps:

  1. Run the following command in the terminal:

    xcode-select --install
  2. A pop-up window should appear prompting you to install the tools. Click "Install" and follow the prompts.

  3. Wait for the installation to complete (this may take a few minutes).

  4. Verify the installation:

    xcode-select --version
  5. Check if essential developer tools like git are available:

    git --version

If you don’t see a pop-up or the command hangs, you can manually install Xcode Command Line Tools from System SettingsSoftware Update.


4. Install Homebrew (Package Manager)

Homebrew simplifies installing development tools.

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

After installation, verify:

brew doctor
brew update

Add Homebrew to Your PATH

Run these commands in your terminal to ensure Homebrew is accessible:

echo >> ~/.zprofile
echo 'eval "$(/opt/homebrew/bin/brew shellenv)"' >> ~/.zprofile
eval "$(/opt/homebrew/bin/brew shellenv)"

Note: Environment variables such as API keys should be stored in your ~/.zshrc or a separate .env file for security. Avoid adding sensitive information directly to ~/.zprofile or ~/.bash_profile.


5. Install a Code Editor

Recommended: Visual Studio Code (VSCode)

To enable VSCode from the Terminal:

  1. Open VSCode
  2. Cmd + Shift + P → Type "Shell Command: Install 'code' command in PATH"

6. Set Up Git

  1. Install Git:
brew install git
  1. Configure your identity:
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
  1. Authenticate GitHub with a Personal Access Token (PAT):

7. Install Node.js with NVM (Node Version Manager)

NVM allows easy version switching.

  1. Install NVM:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash
  1. Add NVM to your shell config (~/.zshrc or ~/.bashrc):
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
  1. Restart your terminal or run:
source ~/.zshrc
  1. Verify installation:
nvm --version
  1. Install and use the latest LTS version of Node.js:
nvm install --lts
nvm alias default lts

8. Install Python and Version Manager

Since macOS ships with a system Python, it's best to use pyenv to manage versions.

  1. Install pyenv:
brew install pyenv
  1. Set up pyenv by adding this to your shell config (~/.zshrc or ~/.bashrc):
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
  1. Restart your terminal or run:
source ~/.zshrc
  1. Install the latest Python version:
pyenv install 3.12.2
pyenv global 3.12.2
  1. Verify Python installation:
python --version

Note: Store environment variables such as API keys in ~/.zshrc or a .env file and use export VAR_NAME=value to set them. To load them automatically, add source ~/.zshrc at the end of your shell startup script.


9. Python Dependency Management: Use uv

uv is a modern, faster replacement for pip, venv, and other dependency managers.

Install uv

brew install uv

Set up a Virtual Environment with uv

export UV_VENV_PATH=".venv"
uv venv
source .venv/bin/activate

Install Dependencies

If you have a requirements.txt file:

uv pip install -r requirements.txt

For individual package installation:

uv add pandas numpy matplotlib jupyterlab

Run JupyterLab

uv run jupyter lab

Lock Dependencies for Reproducibility

uv lock

Sync Dependencies in a New Environment

uv sync

10. Install PostgreSQL + PostGIS

The easiest way to manage PostgreSQL with GIS support is via Postgres.app.

Alternatively, install it via Homebrew:

brew install postgresql postgis
brew services start postgresql

11. Install QGIS (for GIS Work)

Download and install QGIS from its website:

brew install --cask qgis

12. Install GDAL (for Geospatial Data Processing)

Required for working with geospatial files.

brew install gdal

Verify installation:

gdalinfo --version

13. Install Additional Useful Packages

Common Python Libraries

pip install numpy pandas matplotlib seaborn geopandas requests jupyterlab

Docker (for Containerized Development)

brew install --cask docker

Open Docker Desktop and follow the setup instructions.

fzf (Fuzzy Finder for Terminal)

brew install fzf
$(brew --prefix)/opt/fzf/install

ripgrep (Better Grep)

brew install ripgrep

14. Optional: Configure Your Shell

If you prefer zsh (default on macOS), enhance it with:

Oh My Zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Enable zsh-autosuggestions & syntax highlighting

brew install zsh-autosuggestions zsh-syntax-highlighting

Add this to ~/.zshrc:

source $(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh
source $(brew --prefix)/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

Apply changes:

source ~/.zshrc