Search code examples
runtime-errordbt

Installed dbt and was working fine, but getting db cmdlet, function error


Issue: Installed dbt and created a project, defined models and ran some tests. Getting this error now while executing dbt.

dbt : The term 'dbt' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • dbt run -m eve-source
  •   + CategoryInfo          : ObjectNotFound: (dbt:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException
    
    

System and IDE: Windows 10 and VSCode Python version: 3.7.3

dbt works fine from the Powershell prompt, but I want it to work with VSCode as well. Please help me with this. Thank you.


Solution

  • For dbt and vscode workflow, I use the following installation:


    Application:

    • VS Code v1.49.0

    Extensions:

    Project Dir:

      project_dbt
          | .vscode
          |  > dbt.code-workspace
          |  > settings.json
          | analysis
          | macros
          | models
          | seed
          | tests
          | .gitignore
          | dbt_project.yml
          | packages.yml
          | Readme.md
    

    Where dbt.code-workspace contents are:

    {
        "folders": [
            {
                "path": ".."
            }
        ],
        "settings": {}
    }
    

    And settings.json contents are:

    {
        "python.pythonPath": "C:\\tools\\miniconda3\\envs\\dbt\\python.exe"
    }
    

    And then launch python directly to environment via Command Palette Python Ext: enter image description here

    Just adjust your pythonPath to your .venv, conda env, or preferred env manager.