pythonpython-3.xpython-importplotly-dash

AttributeError: module 'typing_extensions' has no attribute 'Generic' during import dash


I'm running python 3.11.2 in a venv (/home/pi/myenv) on a Raspberry Pi Zero. I installed dash in the venv using pip. When running import dash I get the following error:

>>> import dash
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/pi/myenv/lib/python3.11/site-packages/dash/__init__.py", line 46, in <module>
    from ._hooks import hooks  # noqa: F401,E402
    ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/myenv/lib/python3.11/site-packages/dash/_hooks.py", line 29, in <module>
    class _Hook(_tx.Generic[HookDataType]):
                ^^^^^^^^^^^
AttributeError: module 'typing_extensions' has no attribute 'Generic'

The computer is running Linux raspberrypi 6.12.47+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.47-1+rpt1~bookworm (2025-09-16) aarch64 GNU/Linux. The packages are installed as

typing_extensions in /usr/lib/python3/dist-packages (4.4.0)
dash in ~/myenv/lib/python3.11/site-packages (3.3.0)

Solution

  • Thanks to @MrXerios for his suggestion.

    pip install -U typing_extensions
    

    kept the typing_extensions 4.4.0 from the system and installed the newer typing_extensions 4.4.15 into the virtual environment. Then import dash worked.