Skip to content

[Python 3.13] ModuleNotFoundError: No module named 'imghdr' #24

@itkhanz

Description

@itkhanz

Steps to reproduce:

  • Install pyenv Python package manager

  • Install python 3.13.3

pyenv install 3.13.3

  • Make python 3.13.3. global

pyenv global 3.13.3

  • Install mitmproxy version 9.0.0

pipx install mitmproxy==9.0.0

  • install websockets

pipx install websockets

  • Run mitmproxy from terminal

mitmproxy or mitmproxy --version

Actual Result:

Traceback (most recent call last):
  File "/Users/john.doe/.local/bin/mitmproxy", line 8, in <module>
    sys.exit(mitmproxy())
             ~~~~~~~~~^^
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/tools/main.py", line 124, in mitmproxy
    from mitmproxy.tools import console
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/tools/console/__init__.py", line 1, in <module>
    from mitmproxy.tools.console import master
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/tools/console/master.py", line 27, in <module>
    from mitmproxy.tools.console import consoleaddons
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/tools/console/consoleaddons.py", line 7, in <module>
    from mitmproxy import contentviews
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/contentviews/__init__.py", line 21, in <module>
    from . import (
    ...<17 lines>...
    )
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/contentviews/image/__init__.py", line 1, in <module>
    from .view import ViewImage
  File "/Users/john.doe/.local/pipx/venvs/mitmproxy/lib/python3.13/site-packages/mitmproxy/contentviews/image/view.py", line 1, in <module>
    import imghdr
ModuleNotFoundError: No module named 'imghdr'

Expected Result:

mitmproxy should start as usual in interactive mode from terminal and starts capturing the network traffic if proxy is set correctly, or it should display the version as it displays when downgraded python to 3.11.8

Mitmproxy: 9.0.1
Python:    3.11.8
OpenSSL:   OpenSSL 3.0.7 1 Nov 2022
Platform:  macOS-15.4-arm64-arm-64bit

More Information

It seems that this modeule has been marked deprecated and removed from the latest python
https://peps.python.org/pep-0594/#imghdr

Test Environment

Mac Silicon chip
macOS Sequoia 15.4
websockets 15.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions