ImportError: cannot import name 'create_distplot' from 'plotly.figure_factory'
Third-person routing text. Fixes ImportError for create_distplot from plotly.figure_factory: plotly 6.0 removed the long-deprecated distplot helper. Pin plotly below 6 or rewrite with plotly.express histograms. Use when an agent hits this on plotly 6+. Not for other figure_factory removals.
TL;DR: plotly 6.0 removed createdistplot from plotly.figurefactory. Pin plotly below 6 as a stopgap, or rewrite the plot with plotly.express histograms.
The error
ImportError: cannot import name 'create_distplot' from 'plotly.figure_factory'Fix it
- Quick stopgap, pin plotly to the 5.x line:
pip install "plotly<6"Expected: create_distplot imports again.
- Durable fix, migrate to plotly express:
import plotly.express as px
fig = px.histogram(x=data, nbins=50, histnorm="probability density")Expected: equivalent distribution plot on plotly 6.
- Verify:
python -c "import plotly; print(plotly.__version__)"Expected: prints the installed version.
When this applies
Use this when code does from plotly.figure_factory import create_distplot on plotly 6+.
When it does not apply
If the error names a different figure_factory helper, check the plotly 6.0 migration guide; several were removed. If plotly itself will not import, reinstall it.
Compatibility
plotly 6.0+. create_distplot existed through plotly 5.x (deprecated).
Root cause
plotly deprecated the figure_factory distplot in the 5.x series and removed it in 6.0, directing users to plotly.express. Code that never migrated breaks at import on the new major version.
Edge cases
Other removed-in-6.0 helpers include createtable and some gantt helpers; grep figurefactory imports when upgrading. If a library you depend on does the old import, upgrade that library or pin plotly.