ImportError: cannot import name 'X' from 'diffusers' (or diffusers.utils, diffusers.models ...): which releases have it
The error has one of three causes: your diffusers is older than the release that added the name, the name was removed, or it moved to another module. Added: FluxPipeline needs diffusers 0.30.0, WanPipeline 0.33.0, StableDiffusion3Pipeline 0.29.0. Removed: the ONNX pipelines in 0.43.0 (2026-11-12; last release with them 0.42.1), the Flax classes in 0.40.0 (2026-08-20; last 0.39.0), the k-diffusion pipelines in 0.37.0 (2026-03-05; last 0.36.0). Moved: randn_tensor left diffusers.utils in 0.21.0 (2023-09-13) and imports from diffusers.utils.torch_utils in every release since 0.12.0. For any other name, in any module of diffusers, paste the error below.
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 diffusers import HunyuanDiTPipeline works from 0.28.1 (2024-06-04), not only from 0.29.0. Every release was then read once from PyPI: 72 top-level names (and 1,439 module-and-name pairs in all) differ, in a release this page did not read, from what the page said for that release (0.1.1 to 0.1.3, which have no git tag, had been given the names of 0.0.2). The lookup now gives those patch releases. The per-minor ranges are unchanged.
Examples:
Runs in your browser on data.json and four more files it loads when needed (1216 KB in all); nothing you paste is sent anywhere. Understands cannot import name, No module named 'diffusers...', module diffusers has no attribute, Failed to import diffusers... and plain from diffusers... import ... lines. Covers 798 top-level names and 37577 module-and-name pairs in 1380 modules.
Which diffusers version added the pipeline, model or scheduler I am importing?
The table gives the first release that exports each name from the top level; with an older diffusers, from diffusers import <name> raises this ImportError, and upgrading to that release or later fixes it. All of these are still in 0.43.0.
| First release | Date (PyPI) | Top-level names it added (a selection) |
|---|---|---|
| 0.36.0 | 2025-12-08 | Flux2Pipeline, ZImagePipeline |
| 0.35.0 | 2025-08-19 | FluxKontextPipeline, QwenImagePipeline, ModularPipeline |
| 0.34.0 | 2025-06-24 | HiDreamImagePipeline, ChromaPipeline |
| 0.33.0 | 2025-04-09 | WanPipeline, AutoModel, Lumina2Pipeline, QuantoConfig |
| 0.32.0 | 2024-12-23 | FluxFillPipeline, HunyuanVideoPipeline, SanaPipeline, LTXPipeline, GGUFQuantizationConfig, TorchAoConfig |
| 0.31.0 | 2024-10-22 | FluxControlNetPipeline, BitsAndBytesConfig |
| 0.30.0 | 2024-08-07 | FluxPipeline, FluxTransformer2DModel, CogVideoXPipeline, StableAudioPipeline, AuraFlowPipeline |
| 0.29.0 | 2024-06-12 | StableDiffusion3Pipeline, SD3Transformer2DModel, FlowMatchEulerDiscreteScheduler |
| 0.26.0 | 2024-01-31 | I2VGenXLPipeline |
| 0.24.0 | 2023-11-29 | StableVideoDiffusionPipeline |
| 0.22.0 | 2023-11-06 | LCMScheduler, AnimateDiffPipeline, MotionAdapter, PixArtAlphaPipeline |
| 0.19.0 | 2023-07-26 | AutoPipelineForText2Image, T2IAdapter |
| 0.18.0 | 2023-07-06 | StableDiffusionXLPipeline, KandinskyV22Pipeline |
| 0.16.0 | 2023-04-26 | IFPipeline |
| 0.15.0 | 2023-04-12 | TextToVideoSDPipeline |
| 0.14.0 | 2023-03-03 | ControlNetModel, StableDiffusionControlNetPipeline |
| 0.13.0 | 2023-02-17 | UniPCMultistepScheduler |
| 0.10.0 | 2022-12-08 | StableDiffusionDepth2ImgPipeline |
| 0.8.0 | 2022-11-23 | DPMSolverMultistepScheduler |
| 0.7.0 | 2022-11-03 | EulerDiscreteScheduler, EulerAncestralDiscreteScheduler |
| 0.3.0 | 2022-09-08 | StableDiffusionImg2ImgPipeline, StableDiffusionInpaintPipeline |
| 0.2.0 | 2022-08-16 | StableDiffusionPipeline |
A selection of 49 of the 747 names in 0.43.0; the lookup has all of them. A development install such as 0.30.0.dev0 has only what was merged when it was built, so it can lack a name that the final 0.30.0 has.
What did each diffusers release remove from the top level?
51 of the 798 names that from diffusers import ... has ever accepted are gone from 0.43.0; this is every one of them, by the release that dropped it. To keep old code running, pin below that release, for example pip install "diffusers<0.43.0" for the ONNX pipelines.
| Release | Date (PyPI) | Names | Gone from the top level |
|---|---|---|---|
| 0.43.0 | 2026-11-12 | 6 | OnnxRuntimeModel, OnnxStableDiffusionImg2ImgPipeline, OnnxStableDiffusionInpaintPipeline, OnnxStableDiffusionPipeline, OnnxStableDiffusionUpscalePipeline, StableDiffusionOnnxPipelinethe ONNX Runtime pipelines and OnnxRuntimeModel. The message in 0.42.1: "Please use Optimum for ONNX Runtime support." |
| 0.41.0 | 2026-10-06 | 2 | Lumina2Text2ImgPipeline, LuminaText2ImgPipeline |
| 0.40.0 | 2026-08-20 | 20 | FlaxAutoencoderKL, FlaxControlNetModel, FlaxDDIMScheduler, FlaxDDPMScheduler, FlaxDPMSolverMultistepScheduler, FlaxDiffusionPipeline, FlaxEulerDiscreteScheduler, FlaxKarrasVeScheduler, FlaxLMSDiscreteScheduler, FlaxModelMixin, FlaxPNDMScheduler, FlaxSchedulerMixin, FlaxScoreSdeVeScheduler, FlaxStableDiffusionControlNetPipeline, FlaxStableDiffusionImg2ImgPipeline, FlaxStableDiffusionInpaintPipeline, FlaxStableDiffusionPipeline, FlaxStableDiffusionXLPipeline, FlaxUNet2DConditionModel, is_flax_availableevery Flax class. The message in 0.39.0: "Flax classes are deprecated and will be removed in Diffusers v0.40.0. We recommend migrating to PyTorch classes or pinning your version of Diffusers." |
| 0.37.0 | 2026-03-05 | 6 | StableDiffusionKDiffusionPipeline, StableDiffusionXLKDiffusionPipeline, Wan22AutoBlocks, WanAutoBlocks, is_k_diffusion_available, is_k_diffusion_versionthe k-diffusion pipelines and their availability checks |
| 0.25.0 | 2023-12-27 | 1 | OnnxStableDiffusionInpaintPipelineLegacythe name stayed in the lazy table until 0.42.1, but the file behind it was removed here (see below) |
| 0.22.0 | 2023-11-06 | 1 | pipeline_utilsthe old module diffusers.pipeline_utils; use diffusers.pipelines.pipeline_utils, or import DiffusionPipeline from diffusers |
| 0.16.0 | 2023-04-26 | 1 | TextualInversionLoaderMixin |
| 0.12.0 | 2023-01-25 | 7 | dynamic_modules_utils, hub_utils, modeling_flax_pytorch_utils, modeling_flax_utils, modeling_utils, onnx_utils, pipeline_flax_utilsold top-level modules; the same files live under diffusers.models, diffusers.pipelines and diffusers.utils |
| 0.11.0 | 2022-12-19 | 1 | transformers |
| 0.8.0 | 2022-11-23 | 2 | error_msg, is_accelerate_available |
| 0.4.0 | 2022-10-06 | 1 | testing_utils |
| 0.2.0 | 2022-08-16 | 3 | GaussianDDPMScheduler, UNetGLIDEModel, UNetModel |
Lower-case entries such as pipeline_utils and hub_utils are modules that used to sit directly under diffusers.
The name is still in diffusers but my import path fails. Where did it go?
diffusers has moved files several times, and an import that names the old module fails even though the class still exists. 228 of the 1380 modules that have existed are gone from 0.43.0; the releases that removed or moved the most are 0.25.0 (54), 0.37.0 (15), 0.38.0 (67), 0.40.0 (29). The safest import is the shortest one that works: from diffusers import UNet2DConditionModel has worked in every release since 0.2.0, while from diffusers.models.unet_2d_condition import UNet2DConditionModel stopped in 0.29.0.
| Old import | Works in | Stops in | Use instead |
|---|---|---|---|
from diffusers.utils import randn_tensor | 0.12.0 to 0.20.2 | 0.21.0 (2023-09-13) | from diffusers.utils.torch_utils import randn_tensor (same function; that import works in every release from 0.12.0). |
from diffusers.utils import torch_device | 0.4.0 to 0.20.2 | 0.21.0 (2023-09-13) | from diffusers.utils.testing_utils import torch_device, or write "cuda" if torch.cuda.is_available() else "cpu": it is a test helper. |
from diffusers.utils import floats_tensor | 0.4.0 to 0.20.2 | 0.21.0 (2023-09-13) | from diffusers.utils.testing_utils import floats_tensor (a test helper). |
from diffusers.utils import HF_HUB_OFFLINE | 0.12.0 to 0.24.0 | 0.25.0 (2023-12-27) | from huggingface_hub.constants import HF_HUB_OFFLINE: from 0.25.0 diffusers reads the constant from huggingface_hub. |
from diffusers.utils import DIFFUSERS_CACHE | 0.2.0 to 0.24.0 | 0.25.0 (2023-12-27) | from huggingface_hub.constants import HF_HUB_CACHE: from 0.25.0 diffusers uses the cache directory of huggingface_hub. |
from diffusers.models.embeddings import PositionNet | 0.20.0 to 0.25.1 | 0.26.0 (2024-01-31) | GLIGENTextBoundingboxProjection in the same module: the class was renamed in 0.26.0. |
diffusers.pipeline_utils (module) | 0.0.2 to 0.21.4 | 0.22.0 (2023-11-06) | diffusers.pipelines.pipeline_utils (the old module said: "Please import from diffusers.pipelines.pipeline_utils instead."), or simply from diffusers import DiffusionPipeline |
diffusers.modeling_utils (module) | 0.0.2 to 0.11.1 | 0.12.0 (2023-01-25) | diffusers.models.modeling_utils |
diffusers.models.cross_attention (module) | 0.12.0 to 0.19.3 | 0.20.0 (2023-08-17) | diffusers.models.attention_processor (CrossAttention is Attention there; the old module said: "Importing from cross_attention is deprecated. Please import from diffusers.models.attention_processor instead.") |
diffusers.models.unet_2d_condition (module) | 0.2.0 to 0.28.2 | 0.29.0 (2024-06-12) | diffusers.models.unets.unet_2d_condition |
diffusers.models.unet_2d_blocks (module) | 0.7.0 to 0.28.2 | 0.29.0 (2024-06-12) | diffusers.models.unets.unet_2d_blocks |
diffusers.models.transformer_2d (module) | 0.12.0 to 0.28.2 | 0.29.0 (2024-06-12) | diffusers.models.transformers.transformer_2d |
diffusers.models.autoencoder_kl (module) | 0.12.0 to 0.24.0 | 0.25.0 (2023-12-27) | diffusers.models.autoencoders.autoencoder_kl |
diffusers.models.vae (module) | 0.2.0 to 0.24.0 | 0.25.0 (2023-12-27) | diffusers.models.autoencoders.vae |
diffusers.models.controlnet (module) | 0.14.0 to 0.36.0 | 0.37.0 (2026-03-05) | diffusers.models.controlnets.controlnet |
diffusers.models.controlnet_flux (module) | 0.31.0 to 0.36.0 | 0.37.0 (2026-03-05) | diffusers.models.controlnets.controlnet_flux |
diffusers.models.controlnet_sd3 (module) | 0.30.0 to 0.36.0 | 0.37.0 (2026-03-05) | diffusers.models.controlnets.controlnet_sd3 |
diffusers.pipelines.controlnet.multicontrolnet (module) | 0.17.0 to 0.40.0 | 0.41.0 (2026-10-06) | diffusers.models.controlnets.multicontrolnet |
diffusers.schedulers.scheduling_karras_ve (module) | 0.2.0 to 0.23.1 | 0.24.0 (2023-11-29) | diffusers.schedulers.deprecated.scheduling_karras_ve |
For a module, "use instead" is the module with the same file name in 0.43.0. The lookup does this for any module or name: paste No module named 'diffusers...' or the import line.
Which names does diffusers list but fail to import?
15 entries of the lazy import tables point at a file that is gone or at a file that does not define the name; the import fails although the name is in the table, in dir() and in autocompletion. 5 of them are still there in 0.43.0. The best-known one: from diffusers import OnnxStableDiffusionInpaintPipelineLegacy stopped working in 0.25.0, when its file was removed, but the top-level table kept the name until 0.42.1. With onnxruntime installed the import raises; without it, diffusers hands back a placeholder class that raises when used.
| Import | Fails in | Why |
|---|---|---|
from diffusers import OnnxStableDiffusionInpaintPipelineLegacy | 0.25.0 to 0.42.1 | the entry goes through diffusers.pipelines, which no longer has it |
from diffusers.pipelines.cogview3 import CogView3PlusPipelineOutput | 0.31.0 to 0.43.0 (still) | pipeline_output.py is there but does not provide that name |
from diffusers.pipelines.cogview4 import CogView4PlusPipelineOutput | 0.33.0 to 0.43.0 (still) | pipeline_output.py is there but does not provide that name |
from diffusers.pipelines.deprecated.stable_diffusion_safe import StableDiffusionSafetyChecker | 0.38.0 to 0.43.0 (still) | safety_checker.py is there but does not provide that name |
from diffusers.pipelines.qwenimage import QwenImagePriorReduxPipelineOutput | 0.35.0 to 0.43.0 (still) | pipeline_output.py is there but does not provide that name |
from diffusers.pipelines.qwenimage import ReduxImageEncoder | 0.35.0 to 0.43.0 (still) | the entry points to modeling_qwenimage.py, which is not there |
from diffusers.pipelines.stable_diffusion import CycleDiffusionPipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_cycle_diffusion.py, which is not there |
from diffusers.pipelines.stable_diffusion import OnnxStableDiffusionInpaintPipelineLegacy | 0.25.0 to 0.42.1 | the entry points to pipeline_onnx_stable_diffusion_inpaint_legacy.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionAttendAndExcitePipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_attend_and_excite.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionGLIGENPipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_gligen.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionGLIGENTextImagePipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_gligen_text_image.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionInpaintPipelineLegacy | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_inpaint_legacy.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionModelEditingPipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_model_editing.py, which is not there |
from diffusers.pipelines.stable_diffusion import StableDiffusionParadigmsPipeline | 0.25.0 to 0.33.1 | the entry points to pipeline_stable_diffusion_paradigms.py, which is not there |
from diffusers.pipelines.stable_diffusion_safe import StableDiffusionSafetyChecker | 0.21.0 to 0.37.1 | safety_checker.py is there but does not provide that name |
Found by following every table entry to the file it names, in every release. The error is ImportError: cannot import name ... when the file exists, and RuntimeError: Failed to import diffusers... because of the following error (look up to see its traceback) when it does not.
How do I read the error?
- The module after "from" matters as much as the name.
from 'diffusers'is the top level;from 'diffusers.utils'or a longer path is a module whose contents change more often. Paste the whole line so the lookup uses the right module. - The path in parentheses is the copy of diffusers that was imported. Check that it is the version you expect:
python -c "import diffusers as d; print(d.__version__, d.__file__)". In a notebook, restart the kernel after upgrading. - "Failed to import diffusers.pipelines... because of the following error" wraps a second error. If that one names
transformersorhuggingface_hub(cannot import name 'cached_download' from 'huggingface_hub'is the common one), diffusers is fine and the other package is too new or too old: see the pages linked at the bottom. - No error on import, then "requires the torch library" (or transformers, onnxruntime, ...) when the class is used: the name exists, and diffusers gave you a placeholder because that backend is not installed. Install the backend; the diffusers version is not the problem.
- "Did you mean: ...?" at the end is Python's spelling suggestion, not advice from diffusers.
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.
- Up to 0.20.x,
diffusers/__init__.pyimports its names eagerly, and the names are the ones those import statements bind. From 0.21.0 (2023-09-13) the top level and most packages below it replace themselves with a lazy module that serves the names of one table (_import_structure). The table is read along the path taken when the optional backends are installed; each entry is then followed to the file it names, down to the definition. - For any other module, the names are everything it binds at module level: classes, functions, assignments and imports. Code under
if TYPE_CHECKING:is skipped, because it does not run. - The lazy module's own lookup code (
_LazyModule.__getattr__) is checked in every release for rules that look at the spelling of a name; it has none, and the build stops if one appears. - Dates and yanked releases come from PyPI.
Checks, all by a second reading: (1) every lazy package repeats its names as plain imports for type checkers; in 1713 of 2008 package-and-release pairs that block and our reading are identical, and the other pairs differ by 49 names that upstream lists in only one of the two places (the lookup follows the table, which is what runs). (2) Each of the 798 top-level names is found as plain text in __init__.py of every release in its range (12039 name-and-release pairs), and is absent from the release on either side of the range (803 edges). (3) A regular expression finds 60015 class, function and variable definitions in 7595 file versions; all are among the names read. (4) The placeholders the top level hands out when a backend is missing are the same names as the real ones, except for the stale entry above. (5) 23 known facts hold, among them the releases named in the public error reports under Sources.
Limits
- Nothing was installed or run. "Has it" means the import statement resolves in the source; it does not mean the class works with your versions of torch or transformers.
- The ranges use the first release of each minor version. Every release was also read once (102 releases, from the wheels on PyPI, with the same rules): 72 top-level names and 1,439 module-and-name pairs in all differ, in a release this page did not read, from what the page says for that release (all 0.0.x releases count as one minor here; 0.1.1 to 0.1.3 are compared with 0.0.2, whose data the lookup uses for them). The lookup prints those patch releases under the range.
- The answer assumes the optional backends are installed. Without one, a top-level import of a name that needs it still succeeds and returns a placeholder; a few packages below the top level then hand out more placeholders than they have real names.
- Importing a name can still fail for another reason: the file that defines it imports something your transformers or huggingface_hub does not have. That shows up as "Failed to import ..." with a second error underneath.
- "Instead" is given only where the source of the last release with the name states it, or where the same name is defined elsewhere in 0.43.0. Community pipelines (
custom_pipeline=...) and forks are not covered.
Questions
Which diffusers version has FluxPipeline?
diffusers 0.30.0 (2024-08-07) and every release after it. On an older release, or on a 0.30.0.dev0 build made before the pipeline was merged, "from diffusers import FluxPipeline" fails with ImportError. Upgrade: pip install -U "diffusers>=0.30.0".
How do I fix "cannot import name 'randn_tensor' from 'diffusers.utils'"?
Change the import to "from diffusers.utils.torch_utils import randn_tensor". diffusers.utils exported randn_tensor from 0.12.0 through 0.20.2 and stopped in 0.21.0 (2023-09-13); diffusers.utils.torch_utils has had it since 0.12.0, so the new import works on old and new releases. If the import is inside a package you do not maintain, pin instead: pip install "diffusers<0.21.0".
Why can't I import OnnxStableDiffusionPipeline from diffusers any more?
diffusers 0.43.0 (2026-11-12) removed the ONNX Runtime pipelines and OnnxRuntimeModel; 0.42.1 is the last release that has them. The deprecation message in 0.42.1 says: "Please use Optimum for ONNX Runtime support." To keep the old code running: pip install "diffusers<0.43.0".
Which diffusers version removed the Flax classes?
diffusers 0.40.0 (2026-08-20) removed all 20 Flax names from the top level, FlaxStableDiffusionPipeline and FlaxUNet2DConditionModel included; 0.39.0 is the last release that has them. Its message recommends migrating to the PyTorch classes or pinning the version.
My diffusers is newer than the version the name needs, and the import still fails. Why?
Three usual reasons. Another copy of diffusers is being imported: print diffusers.__version__ and diffusers.__file__ in the same interpreter. The install is a development build (for example 0.30.0.dev0) made before the name was merged. Or the error names another package: "Failed to import diffusers.pipelines... because of the following error: cannot import name ... from 'transformers'" is about transformers or huggingface_hub, not diffusers.
The name in my error is not a pipeline. Does this page cover it?
Yes. The lookup covers every name that every module of diffusers binds, from 0.0.2 to 0.43.0: 798 top-level names (51 gone from the newest release) and 37577 module-and-name pairs across 1380 modules, 228 of which no longer exist.
Sources
- huggingface/diffusers, release tags v0.0.2 to v0.43.0: every
.pyfile under src/diffusers; the lazy module is in utils/import_utils.py. - Messages quoted for replacements: pipelines/onnx_utils.py at 0.42.1 (ONNX), pipelines/pipeline_flax_utils.py at 0.39.0 (Flax), pipeline_stable_diffusion_k_diffusion.py at 0.36.0, models/cross_attention.py at 0.19.0, pipeline_utils.py at 0.21.0, models/embeddings.py at 0.26.0 (
GLIGENTextBoundingboxProjection). - Reports of the error this page answers: FluxPipeline on a 0.30.0.dev0 build, StableDiffusionDepth2ImgPipeline on 0.9.0, StableAudioPipeline, WanPipeline, HF_HUB_OFFLINE from diffusers.utils.
- Release dates: PyPI.
The same data as JSON: data.json, names-core.json, names-pipelines.json, names-modular.json, where.json, licensed CC BY 4.0.
Related: "cannot import name ... from 'transformers'": the releases that have each name · "cannot import name 'cached_download' from 'huggingface_hub'" · "got an unexpected keyword argument": PEFT, TRL and TrainingArguments by version.