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.
pip install kagglehubVerified import paths — ran on the pinned version, not inferred.
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.
Understand the scope: `kagglehub` for resource downloading, `kaggle` client for broader API interaction. Don't mix import paths or assume identical functionality.
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.
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.
Install the library using pip: `pip install kagglehub`
Ensure you are authenticated. Options include: 1) Calling `kagglehub.login()` and providing your Kaggle API token (preferably a 'Legacy API credentials' token from Kaggle settings). 2) Setting `KAGGLE_USERNAME` and `KAGGLE_KEY` environment variables. 3) Storing your `kaggle.json` file in `~/.kaggle/kaggle.json` or `~/.kaggle/access_token`. If in Google Colab, use Colab secrets for `KAGGLE_API_TOKEN`.
The `kagglehub` library focuses on programmatic access to models and datasets. If you need to interact with competitions (e.g., downloading competition data), you should use the `kaggle` command-line interface directly (`!kaggle competitions download ...`) or ensure you are running your code within a Kaggle Notebook where `kaggle.competitions` is available. The `kagglehub` library itself does not expose a `kaggle.competitions` module.
Double-check the resource's handle (e.g., `owner_slug/dataset_slug`), the specific file path within the resource, and the version number. Ensure the resource is public or that your authentication grants access to it.
Install `kagglehub` with the required optional dependencies for the adapter you wish to use. For Pandas, use: `pip install kagglehub[pandas-datasets]`. For Hugging Face: `pip install kagglehub[hf-datasets]`. For Polars: `pip install kagglehub[polars-datasets]`.
No dependency data recorded yet.