Installed dbt but getting error "DBT command not found error"
Asked Answered
C

11

11

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: https://docs.getdbt.com/v0.10/docs/windows. 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

Chanteuse answered 2/12, 2019 at 10:24 Comment(1)
Also check that Git for windows is installed. Check the link below for instructions. git-scm.com/downloadsUsia
A
6

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.

Ashlynashman answered 6/7, 2020 at 14:59 Comment(0)
C
5

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.

Careaga answered 24/12, 2022 at 10:52 Comment(0)
S
3

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

Styria answered 20/9, 2021 at 10:24 Comment(0)
B
3

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
Brathwaite answered 28/9, 2023 at 17:58 Comment(0)
A
1

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.
Alleyn answered 2/12, 2019 at 13:17 Comment(0)
O
0

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.

Oxus answered 30/12, 2020 at 14:20 Comment(0)
L
0
  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
Leatherette answered 30/7, 2022 at 13:25 Comment(0)
I
0

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>
Ingenerate answered 1/1, 2023 at 4:32 Comment(0)
F
0
  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.
Fibula answered 18/5, 2023 at 14:54 Comment(0)
S
0

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. (https://docs.getdbt.com/docs/core/pip-install#:~:text=You%20need%20to%20use%20pip,environments%20when%20installing%20with%20pip%20.)

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!

Scrivens answered 26/7, 2023 at 17:54 Comment(0)
G
-1

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
Gabbard answered 16/7, 2020 at 19:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.