Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cannot import name 'models' from 'looker_sdk' #82

Open
FranSimoneTK opened this issue Feb 28, 2024 · 5 comments
Open

cannot import name 'models' from 'looker_sdk' #82

FranSimoneTK opened this issue Feb 28, 2024 · 5 comments

Comments

@FranSimoneTK
Copy link

FranSimoneTK commented Feb 28, 2024

Hello!!
Can you please help me with this error:
after installing and running henry --help I get the following:
Traceback (most recent call last): File "/Users/francisco.simone/Documents/henry/henry/bin/henry", line 5, in <module> from henry.cli import main File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/cli.py", line 7, in <module> from henry.commands import analyze, pulse, vacuum File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/pulse.py", line 5, in <module> from looker_sdk import models ImportError: cannot import name 'models' from 'looker_sdk' (/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/__init__.py)
If I move the models.py to the root folder I'm able to 'run' henry but I get different errors:
Traceback (most recent call last): File "/Users/francisco.simone/Documents/henry/henry/bin/henry", line 8, in <module> sys.exit(main()) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/cli.py", line 20, in main vacuum.Vacuum.run(user_input) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/vacuum.py", line 14, in run result = vacuum.explores(model=user_input.model, explore=user_input.explore) File "/Users/francisco.simone/.pyenv/versions/3.7.17/lib/python3.7/contextlib.py", line 74, in inner return func(*args, **kwds) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/commands/vacuum.py", line 46, in explores field_stats = self.get_explore_field_stats(e) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/modules/fetcher.py", line 288, in get_explore_field_stats model=explore.model_name, explore=explore.name File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/henry/modules/fetcher.py", line 244, in get_used_explore_fields limit="5000", File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/sdk/api40/methods.py", line 9240, in run_inline_query transport_options=transport_options, File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/rtl/api_methods.py", line 180, in post return self._return(response, structure) File "/Users/francisco.simone/Documents/henry/henry/lib/python3.7/site-packages/looker_sdk/rtl/api_methods.py", line 93, in _return raise sdk_error looker_sdk.error.SDKError
Thanks!

@tottipensotti
Copy link

Hi all! I'm also getting the error mentioned above, but it also mention if wanted to use 'models40' instead of 'models'. Just in case it helps to close this issue
ImportError: cannot import name 'models' from 'looker_sdk' (/Users/totti/code/personal_dump/henry/env/lib/python3.12/site-packages/looker_sdk/__init__.py). Did you mean: 'models40'?

@gwilson253
Copy link

I believe the root cause is the import method in henry/commands/pulse.py here. Looking at the looker-sdk API code, there isn't a methods module that can be directly imported from the looker-sdk package.
Rather, this ought to be from looker_sdk.sdk.api40 import methods, as is used in the henry/commands/analyze.py module here.

I fixed this locally and the error resolved... only to uncover a different error on Test 2:

...
looker_sdk.error.SDKError: 
    message:           Must query at least one dimension or measure
...

😞

Also, if there is any guidance on how to set up and run the unit tests I would be more than happy to contribute to this project.

@gwilson253
Copy link

Note - this is fixed in PR #57

@rbob86
Copy link
Collaborator

rbob86 commented Apr 12, 2024

Created a PR with all current fixes @ #85

@benhummel
Copy link

FYI, the changes in those PRs are not live on PyPi, meaning if you install with pip install henry you won't get them. Try doing pip install git+https://github.com/looker-open-source/henry.git@master instead, this will make sure you're on the latest version including this fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants