diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py index 19aa4bb3e51..4ff085156ce 100644 --- a/packages/python/plotly/plotly/express/__init__.py +++ b/packages/python/plotly/plotly/express/__init__.py @@ -2,6 +2,16 @@ `plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \ data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express """ +from __future__ import absolute_import +from plotly import optional_imports + +pd = optional_imports.get_module("pandas") +if pd is None: + raise ImportError( + """\ +Plotly express requires pandas to be installed.""" + ) + from ._chart_types import ( # noqa: F401 scatter, diff --git a/packages/python/plotly/plotly/figure_factory/__init__.py b/packages/python/plotly/plotly/figure_factory/__init__.py index 2b686c8ce3e..3829ca2fb67 100644 --- a/packages/python/plotly/plotly/figure_factory/__init__.py +++ b/packages/python/plotly/plotly/figure_factory/__init__.py @@ -24,18 +24,31 @@ from plotly.figure_factory._scatterplot import create_scatterplotmatrix from plotly.figure_factory._streamline import create_streamline from plotly.figure_factory._table import create_table -from plotly.figure_factory._ternary_contour import create_ternary_contour from plotly.figure_factory._trisurf import create_trisurf from plotly.figure_factory._violin import create_violin if optional_imports.get_module("pandas") is not None: from plotly.figure_factory._county_choropleth import create_choropleth +else: + + def create_choropleth(*args, **kwargs): + raise ImportError("Please install pandas to use `create_choropleth`") + + +if optional_imports.get_module("skimage") is not None: + from plotly.figure_factory._ternary_contour import create_ternary_contour +else: + + def create_ternary_contour(*args, **kwargs): + raise ImportError("Please install scikit-image to use `create_ternary_contour`") + __all__ = [ "create_2d_density", "create_annotated_heatmap", "create_bullet", "create_candlestick", + "create_choropleth", "create_dendrogram", "create_distplot", "create_facet_grid", diff --git a/packages/python/plotly/tox.ini b/packages/python/plotly/tox.ini index df41b7e1df1..d98beda6272 100644 --- a/packages/python/plotly/tox.ini +++ b/packages/python/plotly/tox.ini @@ -74,6 +74,7 @@ deps= optional: pillow==5.2.0 optional: matplotlib==2.2.3 optional: xarray==0.10.9 + optional: pywavelets==1.0.3 optional: scikit-image==0.14.4 ; CORE ENVIRONMENTS