Skip to main content

What are best practices for installing dbt with pip?

Managing Python local environments isn't easy!

First, we recommend using virtual environments to namespace pip modules. Here's an example setup:

python3 -m venv dbt-env             # create the environmentsource dbt-env/bin/activate         # activate the environment

If you install dbt in a virtual environment, that same virtual environment must be re-activated each time a shell window or session is created.

Tip: alias the source ... command in your $HOME/.bashrc, $HOME/.zshrc, or whatever rc file your shell draws from. For example, you can add a command like alias env_dbt='source <...>/bin/activate', where <...> is substituted for the path to your virtual environment configuration.

Second, dbt installations are tested using the latest versions of pip + setuptools. Newer versions have improved behavior around dependency resolution, as well as much faster install times by using precompiled "wheels" when available for your operating system. Before installing, you should ensure that you are using the latest versions:

pip install --upgrade pip wheel setuptools