Answers for LLM inference engineers

ImportError: cannot import name 'X' from 'datasets' (load_metric, list_datasets, ...): which releases have it

Most of these errors come from datasets 3.0.0 (2024-09-11), which removed 30 top-level names; 2.21.0 is the last release that has them. load_metric, list_metrics and Metric moved to the Evaluate library (evaluate.load). list_datasets is now huggingface_hub.list_datasets. set_caching_enabled is now enable_caching or disable_caching. The task templates, such as TextClassification, were dropped with no replacement in datasets. To run old code unchanged, pin pip install "datasets<3.0.0". For any other name, in any module of datasets, paste the error below.

Published 2026-11-18 · Data as of 2026-11-18 · datasets 1.0.0 to 5.2.0, the first release of each of 60 minor versions, with patch releases that differ noted · read from the source of each release tag, nothing was installed or run (how, limits) · Corrected 2026-12-05

Corrected on 2026-12-05: this page read only the first release of each minor version, so a name added or removed in a patch release was dated to the next minor. For example, from datasets import StreamingDownloadManager works from 2.2.2 (2022-05-20), not only from 2.3.0. Every release was then read once from PyPI: 22 top-level names (and 502 module-and-name pairs in all) differ in some patch release from the first release of the same minor. The lookup now gives those patch releases. The per-minor ranges are unchanged.

Examples:

Runs in your browser on datasets.json (152 KB); nothing you paste is sent anywhere. Covers 237 top-level names and 4,933 module-and-name pairs in 189 modules.

What did datasets 3.0.0 remove, and what replaces each name?

These 30 names left from datasets import ... in 3.0.0; each replacement is quoted from the deprecation notes in 2.21.0.

Removed in 3.0.0Use instead
AudioClassificationnone in datasets (task templates were dropped)
AutomaticSpeechRecognitionnone in datasets (task templates were dropped)
BeamBasedBuildernone named
ExpectedMoreDownloadedFilesnone named
ExpectedMoreSplitsnone named
ImageClassificationnone in datasets (task templates were dropped)
LanguageModelingnone in datasets (task templates were dropped)
Metricevaluate (the object evaluate.load returns)
MetricInfoevaluate
QuestionAnsweringExtractivenone in datasets (task templates were dropped)
Summarizationnone in datasets (task templates were dropped)
TaskTemplatenone in datasets (task templates were dropped)
TextClassificationnone in datasets (task templates were dropped)
UnexpectedDownloadedFilenone named
UnexpectedSplitsnone named
_arrow_datasetnone named
_deprecated_download_managernone named
_deprecated_info_utilsnone named
_utilsnone named
beam_utilsnone named
download_managernone named
inspect_datasetnone named
inspect_metricevaluate.inspect_evaluation_module
list_datasetshuggingface_hub.list_datasets
list_metricsevaluate.list_evaluation_modules
load_metricevaluate.load
metricnone named
readmenone named
set_caching_enableddatasets.enable_caching / datasets.disable_caching
tasksnone named

What did each datasets release remove from datasets and datasets.utils?

119 of the 237 names that from datasets import has ever accepted are gone from 5.2.0. Most of the rest left in 1.4.0 and 2.0.0, when the top level stopped passing along everything datasets.utils imported (names like Optional and dill). 36 of the 189 modules that have existed are gone as well; paste No module named 'datasets...' into the lookup for any of them.

ReleaseDate (PyPI)ModuleNamesRemoved names
4.5.02026-01-14datasets1keyhash
3.0.02024-09-11datasets30AudioClassification, AutomaticSpeechRecognition, BeamBasedBuilder, ExpectedMoreDownloadedFiles, ExpectedMoreSplits, ImageClassification, LanguageModeling, Metric, MetricInfo, QuestionAnsweringExtractive, Summarization, TaskTemplate, TextClassification, UnexpectedDownloadedFile, UnexpectedSplits, _arrow_dataset, _deprecated_download_manager, _deprecated_info_utils, _utils, beam_utils, download_manager, inspect_dataset, inspect_metric, list_datasets, list_metrics, load_metric, metric, readme, set_caching_enabled, tasks
3.0.02024-09-11datasets.utils3beam_utils, download_manager, readme
2.19.02024-04-19datasets.utils1_datasets_server
2.16.02023-12-22datasets.utils1__all__
2.14.02023-07-24datasets2platform, pyarrow
2.11.02023-03-29datasets.utils1_hf_hub_fixes
2.6.02022-10-13datasets1SCRIPTS_VERSION
2.3.02022-06-14datasets.utils5DownloadConfig, DownloadManager, DownloadMode, mock_download_manager, streaming_download_manager
2.0.02022-03-15datasets33ArrowReader, ArrowWriter, GenerateMode, KeyHasher, MockDownloadManager, NonMutableDict, _version, cached_path, classproperty, copyfunc, dumps, first_non_null_value, flatten_nest_dict, has_sufficient_disk_space, hf_bucket_url, import_main_class, is_remote_url, map_nested, memoize, mock_download_manager, no_op_if_value_is_null, prepare_module, relative_to_absolute_path, set_progress_bar_enabled, size_str, streaming_download_manager, temp_seed, temporary_assignment, total_allocated_bytes, tqdm_utils, unique_values, zip_dict, zip_nested
2.0.02022-03-15datasets.utils24GenerateMode, MockDownloadManager, NonMutableDict, cached_path, classproperty, copyfunc, dumps, first_non_null_value, flatten_nest_dict, has_sufficient_disk_space, hf_bucket_url, is_remote_url, map_nested, memoize, no_op_if_value_is_null, relative_to_absolute_path, set_progress_bar_enabled, size_str, temp_seed, temporary_assignment, tqdm_utils, unique_values, zip_dict, zip_nested
1.16.02021-11-26datasets1hf_api
1.14.02021-10-19datasets1async_tqdm
1.14.02021-10-19datasets.utils1async_tqdm
1.4.02021-03-03datasets42Callable, ClassVar, CodeType, EmptyTqdm, Final, FunctionType, Generic, INFO, Literal, Optional, Pickler, Pool, RLock, StringIO, Tuple, Union, WARNING, abstractclassmethod, contextlib, datasets_dir, dill, disk_usage, dump, flatten_nested, functools, get_datasets_path, get_logger, get_verbosity, is_notebook, itertools, logger, memoized_property, np, os, pickle, pklregister, regex, save_function, set_verbosity_warning, sys, tqdm_lib, types
1.4.02021-03-03datasets.utils42Callable, ClassVar, CodeType, EmptyTqdm, Final, FunctionType, Generic, INFO, Literal, Optional, Pickler, Pool, RLock, StringIO, Tuple, Union, WARNING, abstractclassmethod, contextlib, datasets_dir, dill, disk_usage, dump, flatten_nested, functools, get_datasets_path, get_logger, get_verbosity, is_notebook, itertools, logger, memoized_property, np, os, pickle, pklregister, regex, save_function, set_verbosity_warning, sys, tqdm_lib, types
1.3.02021-02-15datasets5HF_DATASETS_CACHE, HF_METRICS_CACHE, is_beam_available, is_tf_available, is_torch_available
1.3.02021-02-15datasets.utils5HF_DATASETS_CACHE, HF_METRICS_CACHE, is_beam_available, is_tf_available, is_torch_available
1.2.02021-01-04datasets2datasets, metrics
1.1.02020-10-02datasets1SCRIPTS_VERIONS

How do I read the error?

How was this read, and how was it checked?

From the source of each release tag, with Python's ast module; no release was installed or imported. datasets imports eagerly, so a module's names are everything it binds at module level: classes, functions, assignments, imports, and what from .x import * brings in. Code under if TYPE_CHECKING: is skipped. Dates come from PyPI.

Checks, by a second reading: (1) each of the 237 top-level names is found as plain text in __init__.py (or in the modules it star-imports) in every release of its range (7,032 name-and-release pairs), and is not imported there in the release on either side (178 edges). (2) A regular expression finds 23,287 definitions in 1,826 file versions; all are among the names read. (3) 8 known facts hold, among them the release named in the public reports under Sources.

Limits

Questions

How do I fix "cannot import name 'load_metric' from 'datasets'"?

datasets 3.0.0 (2024-09-11) removed load_metric; 2.21.0 is the last release with it. Install the Evaluate library and use evaluate.load: pip install evaluate, then import evaluate; metric = evaluate.load("accuracy"). To keep old code unchanged, pin pip install "datasets<3.0.0".

What else did datasets 3.0.0 remove?

30 top-level names: load_metric, list_metrics, inspect_metric, Metric and MetricInfo (moved to Evaluate), list_datasets (use huggingface_hub.list_datasets), set_caching_enabled (use enable_caching or disable_caching), inspect_dataset, the task templates such as TextClassification, and a few modules. The full list is on this page.

How do I fix "cannot import name 'list_datasets' from 'datasets'"?

Use huggingface_hub.list_datasets, which datasets 2.21.0 already pointed to. datasets 3.0.0 removed its own list_datasets.

The error says "cannot import name ... from 'datasets'" and the path ends in a folder of my project. What is wrong?

A file or folder named datasets in your project (or an old datasets.py) is imported instead of the library. The path in parentheses shows which one; rename yours. The same holds for "unknown location", which means a datasets folder without __init__.py.

Does this page cover names below the top level, like datasets.utils or datasets.arrow_writer?

Yes: every module of datasets from 1.0.0 to 5.2.0, 4,933 module-and-name pairs in 189 modules.

Sources

The same data as JSON: datasets.json, licensed CC BY 4.0.

Related: "cannot import name ... from 'transformers'" · "... from 'huggingface_hub'" · "... from 'peft', 'trl' or 'accelerate'" · "... from 'diffusers'".