looker_sdk doesn't find the client

Nir99
Participant I

Hi,

I’m trying to connect my python code to my looker account.
I’ve downloaded the looker_sdk.

However, when trying to execute my program I get the error:
ImportError: cannot import name ‘client’ from ‘looker_sdk’.

I was able to do :

sdk = looker_sdk.init31()

What am I missing?

Thanks,
Nir.

2 5 786
5 REPLIES 5

Ajy
Observer

Which python version have you installed?

Nir99
Participant I

python- 3.7, looker_sdk = 0.1.3b7

Sharing more of your python script might help so that we can try running it and see what we get. Make sure to remove any API keys!

ben_krock
Participant I

I ran into this the other day when I first started setting up a dev environment to work with the Looker API Python SDK. I was playing around with the example script for test_connection.py from the sdk-python-examples repo. I followed as many of the readme instructions as I could, and I think I was getting the exact same error as you are.

Here’s how I altered the test_connection.py script to get it to work:

test_connection.py (2.0 KB)

It’s been a few days since I was playing around with that, but I -believe- it was working when I last tried.

Also, here’s how I’ve been setting up my .py scripts since then:

import looker_sdk
from looker_sdk import models, error
import exceptions
from typing import Dict, Union
import json

sdk = looker_sdk.init31()  # or init40() for v4.0 API

<'body of script'>

Also note that I have my looker.ini config file in the same folder as my .py scripts. You may have to fidget with the scripts if they are in a different folder.

Hope this helps, and happy API’ing!

Nir99
Participant I

hey,

other it was something in the installation or in the specific version.
anyhow, uninstalling 0.1.38b and re-installing 0.1.37b solved this issue.

Thanks,
Nir.