{"id":2976,"library":"kagglehub","title":"KaggleHub Library","description":"KaggleHub is a Python library that provides a unified interface to programmatically access and download Kaggle resources, primarily models and datasets, outside of the Kaggle platform. It aims to standardize resource paths and simplify integration with other ML frameworks. The current version is 1.0.0, and the library has a frequent release cadence, with minor versions often released every few weeks.","status":"active","version":"1.0.0","language":"en","source_language":"en","source_url":"https://github.com/Kaggle/kagglehub","tags":["kaggle","data science","machine learning","models","datasets","mlops","resource management"],"install":[{"cmd":"pip install kagglehub","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"model_download","correct":"from kagglehub import model_download"},{"symbol":"dataset_download","correct":"from kagglehub import dataset_download"},{"note":"hf_model_download is a top-level function in kagglehub, not nested under a 'model' submodule.","wrong":"from kagglehub import model.hf_model_download","symbol":"hf_model_download","correct":"from kagglehub import hf_model_download"}],"quickstart":{"code":"import os\nfrom kagglehub import model_download\n\n# Ensure KAGGLE_USERNAME and KAGGLE_KEY environment variables are set\n# or a kaggle.json file exists in ~/.kaggle/\n\n# Example: Download a specific version of a model\nmodel_handle = 'google/vit/tensorflow/vit-base-patch16-224-fe/2'\nmodel_path = model_download(model_handle)\n\nprint(f\"Downloaded model path: {model_path}\")\n\n# To run this, you need to have Kaggle API credentials configured.\n# For local testing, ensure your `KAGGLE_USERNAME` and `KAGGLE_KEY`\n# environment variables are set or a `kaggle.json` file is present.\n","lang":"python","description":"This quickstart demonstrates how to download a pre-trained model using `kagglehub.model_download()`. Replace the `model_handle` with the desired model's identifier. For authentication, ensure your Kaggle API credentials (username and key) are set as environment variables (`KAGGLE_USERNAME`, `KAGGLE_KEY`) or available in a `~/.kaggle/kaggle.json` file."},"warnings":[{"fix":"Understand the scope: `kagglehub` for resource downloading, `kaggle` client for broader API interaction. Don't mix import paths or assume identical functionality.","message":"KaggleHub (this library) is distinct from the general 'kaggle' API client. While both interact with Kaggle, KaggleHub focuses specifically on standardizing the download and access of models and datasets, often integrating with other ML frameworks. Users familiar with `kaggle.api` for broader tasks (competitions, submitting, etc.) should note the different purpose and API.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the official KaggleHub documentation or the model/dataset page on Kaggle for the exact resource handle. Pay close attention to slashes and components.","message":"Resource handles for models and datasets follow a specific `owner/model-name/framework/variation/version` (for models) or `owner/dataset-slug` (for datasets) format. Incorrectly formatted handles will lead to download failures.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure your environment variables are correctly set or your `kaggle.json` file is present and contains valid credentials. If running in a Kaggle notebook, authentication is usually handled automatically.","message":"Authentication requires Kaggle API credentials. This typically means setting `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables or having a valid `kaggle.json` file in `~/.kaggle/`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}