ModuleNotFoundError: No module named 'dash.html'

Viewed 3209
import dash
import dash_html_components as html
import dash_core_components as dcc
import plotly.graph_objects as go
import plotly.express as px

while running this code in Jupyter Notebook I am getting an error.what should i do.

ModuleNotFoundError                       
Traceback (most recent call last)/tmp/ipykernel_7237/1432543730.py in <module>
      1 import dash
----> 2 import dash_html_components as html
      3 import dash_core_components as dcc
      4 import plotly.graph_objects as go
      5 import plotly.express as px

~/.local/lib/python3.8/site-packages/dash_html_components/__init__.py in <module>
----> 1 from dash.html import *  # noqa: F401, F403, E402
      2 from dash.html import __version__  # noqa: F401, F403, E402
      3 import warnings
      4 
      5 warnings.warn(ModuleNotFoundError: No module named 'dash.html')
3 Answers

I had named my python file as 'dash.py' and was getting this error. I changed the file name and the issue got resolved.

Try to replace import dash_html_components as html with from dash import html There is a note in init.py of current version, that dash_html_components package is deprecated (link). The other question is if your installation is correct (missing package resp. dependencies), because this error seems to come from source, not from your code. You can try to reinstall dash with something like pip install --upgrade --force-reinstall dash

Try

!pip install --upgrade plotly
!pip install jupyter-dash
Related