Hugging Face (Meta-package)
The `huggingface` PyPI package (version 0.0.1) is a meta-package designed to simplify installation by pulling in the main Hugging Face libraries: `transformers`, `datasets`, and `huggingface_hub`. It does not provide its own direct API functionality. This package typically has a very low release cadence, primarily updating its dependencies.
Common errors
-
AttributeError: module 'huggingface' has no attribute 'pipeline'
cause Trying to import a function/class like `pipeline` directly from the `huggingface` meta-package.fixFunctionality like `pipeline` resides in the `transformers` library. Change your import to `from transformers import pipeline`. -
ModuleNotFoundError: No module named 'huggingface.models'
cause Incorrectly assuming that the `huggingface` meta-package establishes a hierarchical module structure like `huggingface.models` or `huggingface.datasets`.fixThe core libraries (`transformers`, `datasets`, `huggingface_hub`) are installed as separate, top-level packages. You should import from them directly, e.g., `from transformers import AutoModel`.
Warnings
- gotcha The `huggingface` PyPI package is a meta-package (version 0.0.1) and does not provide direct API functionality. It primarily serves to install other core Hugging Face libraries (`transformers`, `datasets`, `huggingface_hub`).
- gotcha Attempting to import or use functionality directly from `huggingface` (e.g., `from huggingface import pipeline`) will result in an `AttributeError` or `ModuleNotFoundError`.
Install
-
pip install huggingface
Imports
- pipeline
from huggingface import pipeline
from transformers import pipeline
- Dataset
from huggingface import Dataset
from datasets import Dataset
- HfApi
from huggingface import HfApi
from huggingface_hub import HfApi
Quickstart
from transformers import pipeline
# The huggingface meta-package itself does not provide an API.
# This quickstart demonstrates typical usage of the `transformers` library,
# which is installed as a dependency by `huggingface`.
classifier = pipeline("sentiment-analysis")
result = classifier("I love using Hugging Face libraries!")
print(result)
# Example of using a dataset (also installed by huggingface meta-package)
from datasets import load_dataset
# dataset = load_dataset("imdb") # Uncomment to load a large dataset
# print(dataset)