Looker SDK for Python
raw JSON → 26.6.1 verified Tue May 12 auth: no python install: verified
The `looker-sdk` is the official Python SDK for interacting with the Looker REST API. It provides a convenient, programmatic way to manage Looker instances, run queries, extract data, and automate workflows. Maintained by Google/Looker, it currently supports API 4.0 and requires Python 3.6+. It's actively developed with regular updates to support new Looker features and API versions.
pip install looker-sdk Common errors
error ModuleNotFoundError: No module named 'looker-sdk' ↓
cause The `looker-sdk` Python package is not installed in your current environment or your environment's Python path is not correctly configured.
fix
Install the Looker SDK using pip:
pip install looker-sdk error ModuleNotFoundError: No module named 'looker_sdk.rtl' ↓
cause This usually indicates an issue with the `looker-sdk` installation, where the `rtl` (runtime library) submodule cannot be found, possibly due to an incomplete installation or a specific version conflict.
fix
Try uninstalling and reinstalling the package:
pip uninstall looker-sdk && pip install looker-sdk. error SDKError: Looker Not Found (404) ↓
cause This error typically occurs when the requested resource (e.g., dashboard, Look, user) does not exist, the API endpoint URL is incorrect (e.g., wrong port or base URL), or the authenticated user lacks the necessary permissions to access that resource.
fix
Verify the API endpoint URL in your
looker.ini or SDK configuration, ensure the resource ID/path is correct, and confirm that the API credentials have the required permissions for the requested operation. Also, ensure you are using the correct API version (e.g., init40() for API 4.0). error Unauthorized (401) ↓
cause Authentication failed because of invalid or expired API credentials (client ID/secret), the API key lacking sufficient permissions, or the authentication token not being passed correctly in the HTTP request.
fix
Check your
looker.ini file or environment variables (LOOKERSDK_CLIENT_ID, LOOKERSDK_CLIENT_SECRET, LOOKERSDK_BASE_URL) to ensure your API credentials are correct and unexpired. Verify that the associated Looker user has the necessary roles and permissions. error ImportError: cannot import name 'client' from 'looker_sdk' ↓
cause In newer versions of the `looker-sdk`, the `client` module is not directly exposed for import. The SDK client is initialized directly via functions like `looker_sdk.init40()`.
fix
Remove the explicit import of
client. Initialize the SDK client directly, for example: sdk = looker_sdk.init40(). Warnings
breaking API 3.x (3.0 and 3.1) has been completely removed in Looker v23.18 (August 2023). Any applications or scripts using `looker_sdk.init31()` or directly calling 3.x API endpoints will fail. ↓
fix Migrate your code to use Looker API 4.0 and initialize the SDK with `looker_sdk.init40()`. Update any API endpoint calls to their 4.0 equivalents.
breaking Beginning with Looker 26.18 (expected October 2026), credentials for API login will *exclusively* be accepted in the HTTP request body. Passing credentials via URL query parameters will no longer be supported. ↓
fix Upgrade your `looker-sdk` to version 26.4 or later as soon as possible. Modify any custom scripts or applications that manually pass credentials in URL query parameters to pass them in the HTTP request body.
gotcha Storing API credentials directly in a `looker.ini` file or environment variables without proper security measures is a risk. For production environments, consider more secure storage solutions. ↓
fix While `looker.ini` or environment variables are convenient for development, ensure `looker.ini` is never committed to source control (e.g., add to `.gitignore`). For production, implement a secure configuration retrieval method (e.g., using a secrets manager) by subclassing `api_settings.ApiSettings` and overriding `read_config` or using secure environment variable management.
gotcha The base URL for your Looker instance can vary, especially between AWS and Google Cloud Platform (GCP) hosted instances, potentially requiring a port number. ↓
fix For AWS-hosted Looker, the `LOOKERSDK_BASE_URL` might require `:19999` (e.g., `https://your.looker.com:19999`). For GCP instances (e.g., `your.cloud.looker.com`), the port is typically omitted. Verify the correct base URL for your specific Looker instance.
deprecated The `lookerapi` Python package (installed via `pip install lookerapi-deprecated`) is an unofficial, unsupported SDK that was fully removed by the end of 2020. It will not receive updates and may not work with newer Python versions or Looker API changes. ↓
fix Migrate to the official `looker-sdk` package (`pip install looker-sdk`) for all new and existing projects.
Install compatibility verified last tested: 2026-05-12
python os / libc status wheel install import disk
3.10 alpine (musl) wheel - 1.65s 25.4M
3.10 alpine (musl) - - 1.64s 25.3M
3.10 slim (glibc) wheel 2.6s 1.10s 26M
3.10 slim (glibc) - - 1.10s 26M
3.11 alpine (musl) wheel - 2.65s 28.1M
3.11 alpine (musl) - - 2.99s 28.1M
3.11 slim (glibc) wheel 2.6s 2.30s 29M
3.11 slim (glibc) - - 2.21s 29M
3.12 alpine (musl) wheel - 2.08s 19.7M
3.12 alpine (musl) - - 2.36s 19.7M
3.12 slim (glibc) wheel 2.3s 2.16s 20M
3.12 slim (glibc) - - 2.28s 20M
3.13 alpine (musl) wheel - 2.12s 19.5M
3.13 alpine (musl) - - 2.22s 19.4M
3.13 slim (glibc) wheel 2.3s 2.04s 20M
3.13 slim (glibc) - - 2.25s 20M
3.9 alpine (musl) wheel - 1.46s 24.7M
3.9 alpine (musl) - - 1.54s 24.7M
3.9 slim (glibc) wheel 3.1s 1.29s 25M
3.9 slim (glibc) - - 1.31s 25M
Imports
- looker_sdk
import looker_sdk - init40 wrong
sdk = looker_sdk.init31()correctsdk = looker_sdk.init40() - models
from looker_sdk import models
Quickstart last tested: 2026-04-24
import os
import looker_sdk
# --- Configuration using Environment Variables ---
# Set these environment variables before running:
# LOOKERSDK_BASE_URL: Your Looker instance URL (e.g., https://your.looker.com or https://your.looker.cloud.google.com)
# Note: AWS-hosted instances may require ':19999' port (e.g., https://your.looker.com:19999), while GCP-hosted instances usually omit it.
# LOOKERSDK_API_VERSION: Should be '4.0'
# LOOKERSDK_VERIFY_SSL: 'true' or 'false'
# LOOKERSDK_CLIENT_ID: Your API3 Client ID
# LOOKERSDK_CLIENT_SECRET: Your API3 Client Secret
# LOOKERSDK_TIMEOUT: (Optional) Request timeout in seconds, default is 120.
# Example of setting environment variables (replace with your actual values):
os.environ['LOOKERSDK_BASE_URL'] = os.environ.get('LOOKERSDK_BASE_URL', 'https://your.looker.com')
os.environ['LOOKERSDK_API_VERSION'] = os.environ.get('LOOKERSDK_API_VERSION', '4.0')
os.environ['LOOKERSDK_VERIFY_SSL'] = os.environ.get('LOOKERSDK_VERIFY_SSL', 'true')
os.environ['LOOKERSDK_CLIENT_ID'] = os.environ.get('LOOKERSDK_CLIENT_ID', 'YOUR_CLIENT_ID')
os.environ['LOOKERSDK_CLIENT_SECRET'] = os.environ.get('LOOKERSDK_CLIENT_SECRET', 'YOUR_CLIENT_SECRET')
# Initialize the SDK for API 4.0
try:
sdk = looker_sdk.init40()
print("Looker SDK 4.0 initialized successfully.")
# Make a simple API call to get the current user
me = sdk.me()
print(f"Hello, {me.first_name} {me.last_name} ({me.email})!")
# Example of creating a user (requires appropriate permissions)
# from looker_sdk import models
# new_user_data = models.WriteUser(first_name="Test", last_name="User", email="test.user@example.com")
# new_user = sdk.create_user(body=new_user_data)
# print(f"Created new user: {new_user.first_name}")
except Exception as e:
print(f"Error initializing SDK or making API call: {e}")
print("Please ensure environment variables (LOOKERSDK_BASE_URL, LOOKERSDK_API_VERSION, CLIENT_ID, CLIENT_SECRET) are correctly set.")