Dashlane/dbt-invoke

dbt-invoke fails to load - "No module named 'dbt'" on python 3.8.19

extrobe opened this issue · 4 comments

A couple of us have been trying to try out dbt-invoke. Install works fine, but dbt-invoke --help returns the error ModuleNotFoundError: No module named 'dbt'

This is on Python versions 3.9.5 and 3.8.19, and dbt version 0.19.1

Full error message

Traceback (most recent call last):
  File "/usr/local/bin/dbt-invoke", line 5, in <module>
    from dbt_invoke.main import program
  File "/usr/local/lib/python3.9/site-packages/dbt_invoke/main.py", line 3, in <module>
    from dbt_invoke import properties
  File "/usr/local/lib/python3.9/site-packages/dbt_invoke/properties.py", line 8, in <module>
    from dbt_invoke.internal import _utils
  File "/usr/local/lib/python3.9/site-packages/dbt_invoke/internal/_utils.py", line 8, in <module>
    from dbt.task.base import get_nearest_project_dir
ModuleNotFoundError: No module named 'dbt'

My apologies for missing this comment earlier @extrobe. I think my notification settings were messed up. Thank you for trying out dbt-invoke and for reporting this issue!

I tested on Python 3.9.5 and dbt 0.19.1. My output looks good (included below).

Is it possible that dbt and dbt-invoke packages were installed into different locations?

Can you try to run pip freeze to confirm that you see both packages?

You can also try pip show dbt-invoke and pip show dbt to check that the Locations match.

> python --version
Python 3.9.5
> dbt --version
installed version: 0.19.1
   latest version: 0.19.1

Up to date!

Plugins:
> dbt-invoke --help
Usage: dbt-invoke [--core-opts] <subcommand> [--subcommand-opts] ...

Core options:

  --complete                         Print tab-completion candidates for given parse remainder.
  --hide=STRING                      Set default value of run()'s 'hide' kwarg.
  --print-completion-script=STRING   Print the tab-completion script for your preferred shell (bash|zsh|fish).
  --prompt-for-sudo-password         Prompt user at start of session for the sudo.password config value.
  --write-pyc                        Enable creation of .pyc files.
  -d, --debug                        Enable debug output.
  -D INT, --list-depth=INT           When listing tasks, only show the first INT levels.
  -e, --echo                         Echo executed commands before running.
  -f STRING, --config=STRING         Runtime configuration file to use.
  -F STRING, --list-format=STRING    Change the display format used when listing tasks. Should be one of: flat (default), nested, json.
  -h [STRING], --help[=STRING]       Show core or per-task help and exit.
  -l [STRING], --list[=STRING]       List available tasks, optionally limited to a namespace.
  -p, --pty                          Use a pty when executing shell commands.
  -R, --dry                          Echo commands instead of running.
  -T INT, --command-timeout=INT      Specify a global command execution timeout, in seconds.
  -V, --version                      Show version and exit.
  -w, --warn-only                    Warn, instead of failing, when shell commands fail.

Subcommands:

  properties.delete                Delete property file(s) for the specified set of resources
  properties.echo-macro            Print out the configured macro for the user to
  properties.update (properties)   Update property file(s) for the specified set of resources

I am closing this issue for now due to inactivity, but feel free to comment so that we can dig in further if the troubleshooting suggestions did not help.

Most likely happens because on macOS the recommended way is to install using Homebrew.

Which installs it's own Python into:

/usr/local/Cellar/dbt/${DBT_VERSION}/libexec/bin/

Is there a way to tell dbt-invoke to look for dbt at a different location?

FYI can install next to dbt the following way:

/usr/local/Cellar/dbt/0.20.1_1/libexec/bin/pip install dbt-invoke