How to Set Up dbt on Mac (Step-by-Step)
Database Tycoon
A full-service data engineering consultancy with an open-source-first ethos
So, you’re ready to set up dbt on your Mac? Awesome! Whether you’re starting fresh or need to set things up for an existing project, this guide will walk you through everything you need. We’ll cover creating a Python virtual environment (a must for dbt), setting up Git, configuring your profiles.yml file, and installing dbt—all without getting too technical.
You’ll have dbt installed and ready to transform your data like a pro by the end. Let’s dive in!
Step 1: Create Your Project Folder
First things first: You’ll need a folder where your dbt project will live. Think of this folder as your dbt command center, holding your models, virtual environment, and configuration files.
Open Terminal (you can use Spotlight Search—hit Cmd + Space and type “Terminal”). Type the following commands to create and enter your project folder:
mkdir my_dbt_project
cd my_dbt_project
Done! You’re inside your new project folder.
Step 2: Set Up Git
If you’re using version control (and you should!), the next step is to initialize Git. You’ve got two options here: start a brand-new repo or clone an existing dbt project.
Starting from scratch? Run:
git init
Boom—your Git repo is ready to track changes.
Already have a dbt project in GitHub (or GitLab)? Clone it instead:
git clone <repository-url>
cd <project-folder-name>
Now you’ve got all your existing files locally!
Step 3: Install Git and Python (If You Don’t Have Them)
Chances are, Git and Python are already installed on your Mac. Let’s double-check:
Check for Git- run this in Terminal:
git --version
If you see a version number, you’re good. If not, install Git with Homebrew:
brew install git
Check for Python- run:
python3 --version
If that doesn’t work, install Python via Homebrew too:
brew install python3
Step 4: Create and Activate a Python Virtual Environment
Now comes one of the most important parts: setting up a virtual environment (a.k.a. venv). This is like giving dbt its own space to live, separate from any other Python projects on your machine. It helps prevent version conflicts and keeps your setup clean.
Create the virtual environment- run:
python3 -m venv venv
This creates a folder named (venv) inside your project.
Activate the virtual environment- run:
source venv/bin/activate
If you see (venv) at the beginning of your terminal prompt, you’re in! Everything you install from now on (like dbt) will stay inside this environment.
Step 5: Set Up the profiles.yml File
The profiles.yml file is dbt’s way of knowing how to connect to your data warehouse (like Snowflake, BigQuery, or Postgres). This file usually lives in a hidden .dbt folder in your home directory.
Finding or Creating the File
To check if you already have the file, run:
ls ~/.dbt
If you see profiles.yml, great! You can open and edit it. If not, create one by running:
mkdir ~/.dbt
touch ~/.dbt/profiles.yml
Example Configuration (for Snowflake)
Here’s a sample profiles.yml to get you started:
my_dbt_project:
outputs:
dev:
type: snowflake
account: <account_name>
user: <username>
password: <password>
role: <role>
database: <database_name>
warehouse: <warehouse_name>
schema: <schema_name>
target: dev
Replace the placeholders with your actual Snowflake details.
Step 6: Install dbt
You’re almost there! Now that your virtual environment is active, you can install dbt. Choose the right dbt adapter for your data warehouse (e.g., dbt-snowflake, dbt-postgres).
Install dbt- run:
(Replace dbt-snowflake with your preferred adapter if needed.)
pip install dbt-core dbt-snowflake
Step 7: Verify Everything’s Working
To make sure dbt is installed correctly, run:
dbt --version
You should see dbt’s version and your installed plugins listed. If that worked, congratulations—you’re all set!
Troubleshooting Tips
If you run into any issues, here are some quick fixes:
Homebrew Isn’t Installed- If you get an error when trying to use Homebrew, you can install it with this command:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Permission Errors: Sometimes, you might need admin access for certain installations. Try adding sudo before the command if you get a “Permission Denied” error.
What’s Next?
Now that dbt is up and running, you can start transforming your data! Some next steps to explore:
Congrats on making it through the setup! ?? If you have any questions, drop a comment or let Database Tycoon know what you’d like to learn next. Happy dbt-ing!
Strategy | Operations | Growth
2 天前Not me taking 1,000 hours the first time I had to set up dbt on my Mac - wish I had this article then ?? Great piece!!
Data Analyst @ Indicium | Trust & Safety Specialist | Python | Tableau
2 天前that's so handy :D I struggled so much last time I had to do it