To run multiple versions of dbt on the same machine, for example to test one project against 0.14 while leaving others on 0.13, I’ve been using the following approach (Mac Only).
pyenv to manage Python versions:
Easiest install is typically via homebrew:
brew update brew install pyenv
Pyenv allows you to run multiple versions of Python side by side without issues.
So, for example, we can install 3.7.1 and then configure our machine to use that globally:
pyenv install 3.7.1 pyenv global 3.7.1
We can then install the current version of dbt (currently 0.13) into this fresh 3.7.1 install, via
pip install dbt
0.13 is now the default version for all of our projects.
In addition, you will want to be able to manage mutiple evironments of the same Python versions on the same machine, so that you can install different packages within in each environment.
For that, we install the
pyenv-virtualenv plugin from
brew install pyenv-virtualenv
We can then create a new virtual environment using the previously installed 3.7.1 that we’ll call
pyenv virtualenv venv371_dbt_014
pyenv virtualenvs will list the newly configured environment.
We can now use this new, separate 3.7.1 environment in one of our dbt projects
~/dev/my_dbt_project, by adding a file to the root of the dbt project, called
.python-version. In this file, we simply add the name of the virtual environment we just created and want to use only for this project for now:
Whenever we navigate to
pyenv will automatically switch to use the
pip list in this folder will show that no packages are installed in this environment, so we’ll install the latest release candidate,
pip install dbt==0.14.0rc1
We can now test 0.14 in just this project, leaving our other projects untouched. If we’re testing 0.14 on a new git branch, we might even want to check the
.python-version file into our repo until we’re done with testing.
To use the global version, 0.13 , simply remove
.python-version from the project folder and reload your terminal.