Skip to content

ImportError: imsave Removed from tifffile – Update Notebook to Use imwrite #343

@cfusterbarcelo

Description

@cfusterbarcelo

Describe the bug
When running the notebook StarDist_2D_ZeroCostDL4Mic, an error occurs due to the removal of the imsave function from the tifffile library in recent versions.

The error message

ImportError: cannot import name 'imsave' from 'tifffile' (/usr/local/lib/python3.11/dist-packages/tifffile/__init__.py)

This happens because imsave was removed in tifffile version 2025.2.18. The recommended replacement is imwrite.

To Reproduce

  1. Open and run the StarDist_2D_ZeroCostDL4Mic notebook.
  2. Execute first and second cells of the notebook that intalls and imports imsave from tifffile.
  3. The error appears, preventing further execution.

Expected behavior
The notebook should execute without errors.

Desktop:

  • OS: Windows 11 Enterprise
  • Browser: tested both in Chrome and Opera

Additional context

  • The issue is due to a breaking change in tifffile: Release notes.
  • A fix would be to replace imsave with imwrite in the affected part of the notebook.
  • Alternatively and as a quick fix, users can downgrade tifffile using:
!pip install tifffile==2022.8.12

but updating the notebook to use imwrite is the best long-term fix.

Metadata

Metadata

Labels

dependenciesPull requests that update a dependency file

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions