Installed dbt but getting error "DBT command not found error"

I would like to use dbt (Data build tool) in one of my project. I am facing hurdle while creating a project or using DBT command.

I have completed the installation process as described on DBT website given here: . DBT installed successfully but when I tried to use DBT command for creating project it gave me error:

'dbt' is not recognized as an internal or external command, operable program or batch file.

I am using windows 10, and I have tried it for python 3.6 as well as python 3.7 version.

any help would be highly appreciated! Thanks

1

11 Answers

In order to execute dbt command you have to be in a folder with a DBT Project. Usually it doesn't work from anywhere.

Think that you can have multiple projects and dbt run will execute models on your current project.

0

In my case forgetting to activate conda/python environment caused the issue. so try to activate the environment.

Step 1: Create and activate a fresh virtual environment

$ python3 -m venv dbt-venv $ source dbt-venv/bin/activate 

Step 2: Install dbt-core and dbt adapter(s)

pip install dbt-core 

Depending on your target database or data warehouse, you'll have to install the corresponding adapter. For instance, for Google BigQuery:

pip install dbt-bigquery 

And you should now be able to run any dbt command.


For more details, you can refer to the guide How to install dbt

It means, either that the program is not installed, or that it can't be accessed from just anywhere. Therefore:

  • Check if the installation has been done successfully, and where the program dbt.* (I believe it's dbt.exe) can be found.
  • In case you've found the file, add the directory to the PATH environment variable of your PC.
0

For dbt to work.

  1. Set up database credentials in the profiles.yml
  2. Run dbt init [project_name]
  3. Go to the directory of the project you just created and run dbt debug this will return an output that shows whether your database credentials are in order and that dbt can connect to the database

I suggest the following

  1. Create environment
python3 -m venv dbt-env 
  1. Activate environment
dbt-env\Scripts\activate 
  1. Check the dbt has been installed correctly
dbt --version 

This is based on the similar installation described in the documentation, although adjusted to Windows.

  1. First check if you are inside the environment where you have installed DBT
  2. Inside environment check dbt version using dbt --version
  3. DBT works where you have created DBT project except for the command - dbt init <project_name> which is used to create a project. Once you have created project inside that you can use any DBT command.
  4. If you can get version of DBT then you should be able to create project and use related commands
  5. If you dont have profiles.yml configured, you will explicitly get error asking for that, in that case configure profiles file using DBT documentation.
  6. Even after creating DBT project you can get errors due to many reasons, which has to be sorted out, but if you are able to run command dbt run -m <model_name.sql> you are good to go

dbt command needs dbt_project.yml to define model paths and test paths and initiate vars and so on.... And dbt gets the current directory as the default path, you can get dir using pwd command

But if you have many projects or want to run dbt from any directory, You need to pass env project-dir that path must have a dbt_project.yml

dbt run --project-dir <project path> 

And likewise, if you have many dbt profiles, You can specify any one for execution with using env profiles-dir

dbt run --profiles-dir <profile path> 
  1. I hope you have run pip install dbt-snowflake or any other database specific run.
  2. You need to check python --version and pip list to confirm python path is correctly set and dbt library is installed.
  3. You can run command dbt init --profiles-dir <directory/folder where you want to have profile file>.
  4. Better to set environment variable DBT_PROFILES_DIR with directory where you want to store your profile. Earlier dbt init was allowed to run without setting this environment variable.
  5. It will keep asking profile directory for all commands now e.g. dbt init, dbt run.

Are you doing this in a virtual environment or locally? If you're installing dbt locally then you should be able to access the dbt command from anywhere in your command line. E.g. dbt --version should give a result if you've installed locally, but if you're installing to a virtual environment then you'd need to spin that up first.

I'd install locally first to rule that out. ()

Run pip install dbt-core in a fresh command line window then once it's finished and you've addressed any additional prompts, restart your command line then try dbt --version again.

Let us know how you get on!

on mac:

pip3 install dbt-bigquery, if problem persists you need to add the directory where the install happened to your path.

  1. find the location of your dbt executable: echo $(python3 -m site --user-base)/bin
  2. Add dir to path (e.g. zsh): vim ~/.zshrc export PATH=/Users/pmo511/Library/Python/3.9/bin:$PATH
  3. Apply change: source ~/.zshrc

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

You Might Also Like