Skip to content

Tensorboard fails in python 3.13 because imghdr module is absent #6964

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Bichidian opened this issue Dec 18, 2024 · 5 comments
Open

Tensorboard fails in python 3.13 because imghdr module is absent #6964

Bichidian opened this issue Dec 18, 2024 · 5 comments

Comments

@Bichidian
Copy link

Running tensorboard --logdir . under python 3.13 leads to the following error:

Traceback (most recent call last):
  File ".venv/bin/tensorboard", line 5, in <module>
    from tensorboard.main import run_main
  File ".venv/lib64/python3.13/site-packages/tensorboard/main.py", line 27, in <module>
    from tensorboard import default
  File ".venv/lib64/python3.13/site-packages/tensorboard/default.py", line 40, in <module>
    from tensorboard.plugins.image import images_plugin
  File ".venv/lib64/python3.13/site-packages/tensorboard/plugins/image/images_plugin.py", line 18, in <module>
    import imghdr
ModuleNotFoundError: No module named 'imghdr'

It seems that imghdr is no longer part of the Python standard library in 3.13.

@arcra
Copy link
Member

arcra commented Dec 20, 2024

Thanks for reporting. We'll look for a replacement for this library.

AFAICT, we only use it to get MIME types, which I expect should be somewhat easily replaceable, but we can't guarantee when we'll address this. In the meantime, Python < 3.13 would be required.

@hzhangxyz
Copy link

You can install standard-imghdr for temporary fix

ELundby45 added a commit to AnacondaRecipes/tensorboard-feedstock that referenced this issue Mar 20, 2025
@E1k3
Copy link

E1k3 commented Mar 28, 2025

Any news on this?
If no work on this has been done, would you be open to one of the following solutions?

  1. Taking on https://github.com/h2non/filetype.py as a dependency to replace the two calls to imagehdr.what
  2. Copying the bmp, gif, jpeg and png matchers from filetype.py (MIT licensed so should be fine) to replace the two calls to imagehdr.what

If one of these is fine, I can submit a PR.

@foxik
Copy link

foxik commented Mar 28, 2025

Given that the imghdr.py from the standard library has <4kB and has only trivial dependencies (os, warnings), I would just add a copy to the TensorBoard codebase? The code is simple, I would expect zero maintenance cost.

@E1k3
Copy link

E1k3 commented Mar 28, 2025

Fine by me, as long as I can use tensorboard with 3.13 without pushing standard-imghdr everywhere.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants