Step-by-Step Guide to Installing DBT in a Virtual Environment

Step-by-Step Guide to Installing DBT in a Virtual Environment

DBT installation guide:

The dbt package will be installed into a Python virtual environment. This allows us to install different versions of dbt (or Python) on your computer and check if the project still works or where it breaks. Therefore, whenever installing a new version of dbt, create a new virtual environment and install the dbt package in it.

  1. I used Ubuntu 22.04 to install dbt-core version 1.8 and virtualenv. First, we will install virtualenv to have a clean, isolated environment.

  2. Install Virtualenv

     sudo apt install virtualenv
    
  3. Create a Virtual Environment

     python3.10 -m venv vm_dbt_package
    
  4. Log into Your Virtual Environment

    First, enter your virtual environment directory

     cd vm_dbt_package
    
  5. Then activate the virtual environment with the command

     source bin/activate
    
  6. Upgrade Pip in Your Virtual Environment

     pip install --upgrade pip
    
  7. It might be necessary to install or upgrade your setuptools package as well

     pip install --upgrade setuptools
    
  8. Install dbt-core and DuckDB as the database adapter

     python -m pip install dbt-core dbt-duckdb
    
  9. Check the dbt version

     dbt --version
    
  10. After the installation of dbt, you can check which packages have been installed in your virtual environment

    pip list
    

You should now see several dbt packages and other Python packages.