Skip to content

Print what package should be installed when suitable writer is missing #7980

Description

@holgerroth

Is your feature request related to a problem? Please describe.
I used SaveImage(..., output_ext=".png") but got this error message

monai.utils.module.OptionalImportError: No ImageWriter backend found for png.

This was after pip install monai in a clean environment.

Describe the solution you'd like
It would be great if the error message would include a description of how to fix the issue, e..g. "Please install pillow". Initially I installed simpleitk which also didn't have the png writer apparently, and I got the same error.

Describe alternatives you've considered
n/a

Additional context
Happened with monai==1.3.2

Activity

  1. holgerroth commented on Aug 1, 2024

    @holgerroth
    CollaboratorAuthor

    Same would apply for LoadImage and image readers for different formats

  2. added 2 commits that reference this issue on Aug 7, 2024
    45aa9a6
    08523ce
  3. Matteoilgiaco commented on Sep 30, 2025

    @Matteoilgiaco

    Hi, can i work on this issue?
    I'm a beginner and i'm a self learner.

  4. holgerroth commented on Sep 30, 2025

    @holgerroth
    CollaboratorAuthor

    Hi @Matteoilgiaco , that would be great! Thanks for your interest in contributing to MONAI.

  5. iloveme81189-del commented on Oct 12, 2025

    @iloveme81189-del

    Can i work on this issue. if the issue resolved can i add on my resume as contribution

  6. holgerroth commented on Oct 12, 2025

    @holgerroth
    CollaboratorAuthor

    @iloveme81189-del. Please coordinate with @Matteoilgiaco. Maybe you two can collaborate on this task?

  7. added a commit that references this issue on Oct 12, 2025
    14ccd76
  8. songhahaha66 commented on Nov 5, 2025

    @songhahaha66

    Hi, I’ve submitted a fix for this issue in PR #8625. The PR adds a clearer error message when SaveImage can’t find a suitable writer and points users to the package they need to install (e.g. Pillow). Please take a look when you have a moment.

  9. 8 remaining items

  10. ericspod commented on May 17, 2026

    @ericspod
    Member

    Hi @vikasreddy11 please see my comment above about the many solutions that have been proposed already. I'd like to coordinate amongst the participants so we can acknowledge everyone's work so I need people to respond. I think your proposed solution in #8853 overlaps with others here but we can integrate these all together somehow. Please give me a bit of time to coordinate here.

  11. aylward commented on May 17, 2026

    @aylward
    Collaborator

    @ericspod - originally the plan was to have ITK/Nibabbel as the primary IO methods. They offer support for the greatest number of formats, including PNG, tiff, .... Perhaps that is a better approach than Pillow et al? Perhaps there is a way to simplify the install options - right now there are over 40. Keep all 40 as-is, but also provide meta-groups: pathology (cucim, tiffile, itk,..), research (tensorboard, pandas, matplotlib), gpu (torch, ...).

  12. ericspod commented on May 21, 2026

    @ericspod
    Member

    @ericspod - originally the plan was to have ITK/Nibabbel as the primary IO methods. They offer support for the greatest number of formats, including PNG, tiff, .... Perhaps that is a better approach than Pillow et al? Perhaps there is a way to simplify the install options - right now there are over 40. Keep all 40 as-is, but also provide meta-groups: pathology (cucim, tiffile, itk,..), research (tensorboard, pandas, matplotlib), gpu (torch, ...).

    We can look to consolidate the dependencies definitely, we do have groups for different components in setup.cfg but we should modernise the configuration files to put these into the pyproject.toml file. One concern using the ITK library is that the package can be upwards of 1.4GiB installed. This might have been an issue in the past with environments like Colab in terms of space.

  13. noorfatimacheema249-design commented on Jun 19, 2026

    @noorfatimacheema249-design

    Hi, I’d like to work on this. My plan: update the SaveImage / writer backend error to include suggested packages by extension (e.g. for png suggest pip install pillow), add a small unit test and open a PR. If there’s any preferred message wording or list of extensions/packages you want me to use, please let me know.

  14. ericspod commented on Jun 25, 2026

    @ericspod
    Member

    Hi @noorfatimacheema249-design I would suggest holding off on working on this issue, there's a number of submissions related to it already. Please have a look at the comment above, I'm trying to coordinate existing efforts and will come back to this shortly. If you have any comments on the existing PRs or the issue itself we definitely appreciate any effort.

  15. ericspod commented on Jul 16, 2026

    @ericspod
    Member

    Hi @NiketGirdhar22 @vectorvp @songhahaha66 @yashnaiduu @haoyu-haoyu @Talhax55z @its-serah, @abishop1990 We have many approaches here to the solution of feedback for missing packages. I feel that #8989 is more of the right direction in that the missing package is stored in the raised exception which can then be used to construct a hint message about what to install. This would then be the approach to use for improving the reader as well which would address issue #7437, perhaps by updating #8522 to use this information. A few of your approaches use fixed lists of dependencies which are looked up to find hint strings, I feel this is less flexible than using the exception to tell us what didn't import. Please have a look at #8989 but I think we'll be going with that shortly, we can then work out what to do with other PRs and credit for contribution.

  16. added 3 commits that reference this issue on Jul 26, 2026
    6fabf99
    ef586f2
    55282c5
  17. added 3 commits that reference this issue on Sep 29, 2026
    56c15a3
    4718664
    5edd731
  18. Pushpak731 commented on Sep 29, 2026

    @Pushpak731

    Hi @ericspod — flagging PR #9142 here since you're coordinating the efforts on this issue. It follows exactly the direction you describe: OptionalImportError stores the missing package name (pkg_name), require_pkg populates it (appending the version constraint, e.g. torch>=10000, when a version is required), and resolve_writer constructs the install hint from the raised exceptions of the unavailable candidate writers. The only lookup is the unavoidable PIL → pillow import-name-to-distribution translation; there are no fixed extension/package tables, so custom require_pkg-decorated writers get hints for free. DCO, pre-commit, DeepSource and CodeRabbit all pass, and tests.min_tests (9.8k tests) passes locally. Happy to defer to #8989 or help consolidate whichever submission you prefer — the same pkg_name mechanism should transfer cleanly to the reader side for #7437/#8522 as well.

  19. Talhax55z commented on Oct 1, 2026

    @Talhax55z
    Contributor

    Hi @ericspod, thanks for coordinating. My PRs #8795 (static install hint) and
    #8796 (LoadImage reader error, related to #7437) use the fixed-list approach, so
    I agree #8989 / #9142 is the better direction. I'm happy to close #8795 in favour
    of those. Once the pkg_name mechanism is merged I can rebase #8796 onto it for the
    reader side, or close it too, whichever you prefer.
    @holgerroth

  20. wajidcodes commented on Oct 10, 2026

    @wajidcodes

    Hi @holgerroth and team,
    I am a Computer Science undergraduate working with deep learning medical datasets in PyTorch. I would love to claim this issue to improve the error messaging logic for missing ImageWriter backends if it is currently available.
    I will trace the execution path where the suitable writer selection fails and add an actionable exception string guiding the user to the correct optional package installation (pip install monai[...]). Please assign this ticket to me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions