prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Does Plotly 4.2.0 depend on scikit-image?
  I failed to `import plotly.figure_factory` because plotly seems not to install `scikit-image` when running `pip install -U plotly`. After I manually installed `scikit-image`, `import plotly.figure_factory` worked.
  
  This was not a problem in version 4.1.1.
  
  But the source code shows it depends on it.
  https://github.com/plotly/plotly.py/blob/b7ad5433c4e0882715781fa6c4816fc7fff62965/packages/python/plotly/plotly/figure_factory/_ternary_contour.py#L11
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `packages/python/plotly/plotly/express/__init__.py`
  Content:
  ```
  1 """
  2 `plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \
  3 data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express
  4 """
  5 
  6 from ._chart_types import (  # noqa: F401
  7     scatter,
  8     scatter_3d,
  9     scatter_polar,
  10     scatter_ternary,
  11     scatter_mapbox,
  12     scatter_geo,
  13     line,
  14     line_3d,
  15     line_polar,
  16     line_ternary,
  17     line_mapbox,
  18     line_geo,
  19     area,
  20     bar,
  21     bar_polar,
  22     violin,
  23     box,
  24     strip,
  25     histogram,
  26     scatter_matrix,
  27     parallel_coordinates,
  28     parallel_categories,
  29     choropleth,
  30     density_contour,
  31     density_heatmap,
  32 )
  33 
  34 from ._core import (  # noqa: F401
  35     set_mapbox_access_token,
  36     defaults,
  37     get_trendline_results,
  38 )
  39 
  40 from . import data, colors  # noqa: F401
  41 
  42 __all__ = [
  43     "scatter",
  44     "scatter_3d",
  45     "scatter_polar",
  46     "scatter_ternary",
  47     "scatter_mapbox",
  48     "scatter_geo",
  49     "scatter_matrix",
  50     "density_contour",
  51     "density_heatmap",
  52     "line",
  53     "line_3d",
  54     "line_polar",
  55     "line_ternary",
  56     "line_mapbox",
  57     "line_geo",
  58     "parallel_coordinates",
  59     "parallel_categories",
  60     "area",
  61     "bar",
  62     "bar_polar",
  63     "violin",
  64     "box",
  65     "strip",
  66     "histogram",
  67     "choropleth",
  68     "data",
  69     "colors",
  70     "set_mapbox_access_token",
  71     "get_trendline_results",
  72 ]
  73
  ```
  
  Path: `packages/python/plotly/plotly/figure_factory/__init__.py`
  Content:
  ```
  1 from __future__ import absolute_import
  2 
  3 from plotly import optional_imports
  4 
  5 # Require that numpy exists for figure_factory
  6 np = optional_imports.get_module("numpy")
  7 if np is None:
  8     raise ImportError(
  9         """\
  10 The figure factory module requires the numpy package"""
  11     )
  12 
  13 
  14 from plotly.figure_factory._2d_density import create_2d_density
  15 from plotly.figure_factory._annotated_heatmap import create_annotated_heatmap
  16 from plotly.figure_factory._bullet import create_bullet
  17 from plotly.figure_factory._candlestick import create_candlestick
  18 from plotly.figure_factory._dendrogram import create_dendrogram
  19 from plotly.figure_factory._distplot import create_distplot
  20 from plotly.figure_factory._facet_grid import create_facet_grid
  21 from plotly.figure_factory._gantt import create_gantt
  22 from plotly.figure_factory._ohlc import create_ohlc
  23 from plotly.figure_factory._quiver import create_quiver
  24 from plotly.figure_factory._scatterplot import create_scatterplotmatrix
  25 from plotly.figure_factory._streamline import create_streamline
  26 from plotly.figure_factory._table import create_table
  27 from plotly.figure_factory._ternary_contour import create_ternary_contour
  28 from plotly.figure_factory._trisurf import create_trisurf
  29 from plotly.figure_factory._violin import create_violin
  30 
  31 if optional_imports.get_module("pandas") is not None:
  32     from plotly.figure_factory._county_choropleth import create_choropleth
  33 
  34 __all__ = [
  35     "create_2d_density",
  36     "create_annotated_heatmap",
  37     "create_bullet",
  38     "create_candlestick",
  39     "create_dendrogram",
  40     "create_distplot",
  41     "create_facet_grid",
  42     "create_gantt",
  43     "create_ohlc",
  44     "create_quiver",
  45     "create_scatterplotmatrix",
  46     "create_streamline",
  47     "create_table",
  48     "create_ternary_contour",
  49     "create_trisurf",
  50     "create_violin",
  51 ]
  52
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py
  --- 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
  --- 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",
  
verification_info: {"golden_diff": "diff --git a/packages/python/plotly/plotly/express/__init__.py b/packages/python/plotly/plotly/express/__init__.py\n--- a/packages/python/plotly/plotly/express/__init__.py\n+++ b/packages/python/plotly/plotly/express/__init__.py\n@@ -2,6 +2,16 @@\n `plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \\\n data exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express\n \"\"\"\n+from __future__ import absolute_import\n+from plotly import optional_imports\n+\n+pd = optional_imports.get_module(\"pandas\")\n+if pd is None:\n+    raise ImportError(\n+        \"\"\"\\\n+Plotly express requires pandas to be installed.\"\"\"\n+    )\n+\n \n from ._chart_types import (  # noqa: F401\n     scatter,\ndiff --git a/packages/python/plotly/plotly/figure_factory/__init__.py b/packages/python/plotly/plotly/figure_factory/__init__.py\n--- a/packages/python/plotly/plotly/figure_factory/__init__.py\n+++ b/packages/python/plotly/plotly/figure_factory/__init__.py\n@@ -24,18 +24,31 @@\n from plotly.figure_factory._scatterplot import create_scatterplotmatrix\n from plotly.figure_factory._streamline import create_streamline\n from plotly.figure_factory._table import create_table\n-from plotly.figure_factory._ternary_contour import create_ternary_contour\n from plotly.figure_factory._trisurf import create_trisurf\n from plotly.figure_factory._violin import create_violin\n \n if optional_imports.get_module(\"pandas\") is not None:\n     from plotly.figure_factory._county_choropleth import create_choropleth\n+else:\n+\n+    def create_choropleth(*args, **kwargs):\n+        raise ImportError(\"Please install pandas to use `create_choropleth`\")\n+\n+\n+if optional_imports.get_module(\"skimage\") is not None:\n+    from plotly.figure_factory._ternary_contour import create_ternary_contour\n+else:\n+\n+    def create_ternary_contour(*args, **kwargs):\n+        raise ImportError(\"Please install scikit-image to use `create_ternary_contour`\")\n+\n \n __all__ = [\n     \"create_2d_density\",\n     \"create_annotated_heatmap\",\n     \"create_bullet\",\n     \"create_candlestick\",\n+    \"create_choropleth\",\n     \"create_dendrogram\",\n     \"create_distplot\",\n     \"create_facet_grid\",\n", "issue": "Does Plotly 4.2.0 depend on scikit-image?\nI failed to `import plotly.figure_factory` because plotly seems not to install `scikit-image` when running `pip install -U plotly`. After I manually installed `scikit-image`, `import plotly.figure_factory` worked.\r\n\r\nThis was not a problem in version 4.1.1.\r\n\r\nBut the source code shows it depends on it.\r\nhttps://github.com/plotly/plotly.py/blob/b7ad5433c4e0882715781fa6c4816fc7fff62965/packages/python/plotly/plotly/figure_factory/_ternary_contour.py#L11\n", "before_files": [{"content": "\"\"\"\n`plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \\\ndata exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express\n\"\"\"\n\nfrom ._chart_types import (  # noqa: F401\n    scatter,\n    scatter_3d,\n    scatter_polar,\n    scatter_ternary,\n    scatter_mapbox,\n    scatter_geo,\n    line,\n    line_3d,\n    line_polar,\n    line_ternary,\n    line_mapbox,\n    line_geo,\n    area,\n    bar,\n    bar_polar,\n    violin,\n    box,\n    strip,\n    histogram,\n    scatter_matrix,\n    parallel_coordinates,\n    parallel_categories,\n    choropleth,\n    density_contour,\n    density_heatmap,\n)\n\nfrom ._core import (  # noqa: F401\n    set_mapbox_access_token,\n    defaults,\n    get_trendline_results,\n)\n\nfrom . import data, colors  # noqa: F401\n\n__all__ = [\n    \"scatter\",\n    \"scatter_3d\",\n    \"scatter_polar\",\n    \"scatter_ternary\",\n    \"scatter_mapbox\",\n    \"scatter_geo\",\n    \"scatter_matrix\",\n    \"density_contour\",\n    \"density_heatmap\",\n    \"line\",\n    \"line_3d\",\n    \"line_polar\",\n    \"line_ternary\",\n    \"line_mapbox\",\n    \"line_geo\",\n    \"parallel_coordinates\",\n    \"parallel_categories\",\n    \"area\",\n    \"bar\",\n    \"bar_polar\",\n    \"violin\",\n    \"box\",\n    \"strip\",\n    \"histogram\",\n    \"choropleth\",\n    \"data\",\n    \"colors\",\n    \"set_mapbox_access_token\",\n    \"get_trendline_results\",\n]\n", "path": "packages/python/plotly/plotly/express/__init__.py"}, {"content": "from __future__ import absolute_import\n\nfrom plotly import optional_imports\n\n# Require that numpy exists for figure_factory\nnp = optional_imports.get_module(\"numpy\")\nif np is None:\n    raise ImportError(\n        \"\"\"\\\nThe figure factory module requires the numpy package\"\"\"\n    )\n\n\nfrom plotly.figure_factory._2d_density import create_2d_density\nfrom plotly.figure_factory._annotated_heatmap import create_annotated_heatmap\nfrom plotly.figure_factory._bullet import create_bullet\nfrom plotly.figure_factory._candlestick import create_candlestick\nfrom plotly.figure_factory._dendrogram import create_dendrogram\nfrom plotly.figure_factory._distplot import create_distplot\nfrom plotly.figure_factory._facet_grid import create_facet_grid\nfrom plotly.figure_factory._gantt import create_gantt\nfrom plotly.figure_factory._ohlc import create_ohlc\nfrom plotly.figure_factory._quiver import create_quiver\nfrom plotly.figure_factory._scatterplot import create_scatterplotmatrix\nfrom plotly.figure_factory._streamline import create_streamline\nfrom plotly.figure_factory._table import create_table\nfrom plotly.figure_factory._ternary_contour import create_ternary_contour\nfrom plotly.figure_factory._trisurf import create_trisurf\nfrom plotly.figure_factory._violin import create_violin\n\nif optional_imports.get_module(\"pandas\") is not None:\n    from plotly.figure_factory._county_choropleth import create_choropleth\n\n__all__ = [\n    \"create_2d_density\",\n    \"create_annotated_heatmap\",\n    \"create_bullet\",\n    \"create_candlestick\",\n    \"create_dendrogram\",\n    \"create_distplot\",\n    \"create_facet_grid\",\n    \"create_gantt\",\n    \"create_ohlc\",\n    \"create_quiver\",\n    \"create_scatterplotmatrix\",\n    \"create_streamline\",\n    \"create_table\",\n    \"create_ternary_contour\",\n    \"create_trisurf\",\n    \"create_violin\",\n]\n", "path": "packages/python/plotly/plotly/figure_factory/__init__.py"}], "after_files": [{"content": "\"\"\"\n`plotly_express` is a terse, consistent, high-level wrapper around `plotly` for rapid \\\ndata exploration and figure generation. See the gallery at https://plotly.github.io/plotly_express\n\"\"\"\nfrom __future__ import absolute_import\nfrom plotly import optional_imports\n\npd = optional_imports.get_module(\"pandas\")\nif pd is None:\n    raise ImportError(\n        \"\"\"\\\nPlotly express requires pandas to be installed.\"\"\"\n    )\n\n\nfrom ._chart_types import (  # noqa: F401\n    scatter,\n    scatter_3d,\n    scatter_polar,\n    scatter_ternary,\n    scatter_mapbox,\n    scatter_geo,\n    line,\n    line_3d,\n    line_polar,\n    line_ternary,\n    line_mapbox,\n    line_geo,\n    area,\n    bar,\n    bar_polar,\n    violin,\n    box,\n    strip,\n    histogram,\n    scatter_matrix,\n    parallel_coordinates,\n    parallel_categories,\n    choropleth,\n    density_contour,\n    density_heatmap,\n)\n\nfrom ._core import (  # noqa: F401\n    set_mapbox_access_token,\n    defaults,\n    get_trendline_results,\n)\n\nfrom . import data, colors  # noqa: F401\n\n__all__ = [\n    \"scatter\",\n    \"scatter_3d\",\n    \"scatter_polar\",\n    \"scatter_ternary\",\n    \"scatter_mapbox\",\n    \"scatter_geo\",\n    \"scatter_matrix\",\n    \"density_contour\",\n    \"density_heatmap\",\n    \"line\",\n    \"line_3d\",\n    \"line_polar\",\n    \"line_ternary\",\n    \"line_mapbox\",\n    \"line_geo\",\n    \"parallel_coordinates\",\n    \"parallel_categories\",\n    \"area\",\n    \"bar\",\n    \"bar_polar\",\n    \"violin\",\n    \"box\",\n    \"strip\",\n    \"histogram\",\n    \"choropleth\",\n    \"data\",\n    \"colors\",\n    \"set_mapbox_access_token\",\n    \"get_trendline_results\",\n]\n", "path": "packages/python/plotly/plotly/express/__init__.py"}, {"content": "from __future__ import absolute_import\n\nfrom plotly import optional_imports\n\n# Require that numpy exists for figure_factory\nnp = optional_imports.get_module(\"numpy\")\nif np is None:\n    raise ImportError(\n        \"\"\"\\\nThe figure factory module requires the numpy package\"\"\"\n    )\n\n\nfrom plotly.figure_factory._2d_density import create_2d_density\nfrom plotly.figure_factory._annotated_heatmap import create_annotated_heatmap\nfrom plotly.figure_factory._bullet import create_bullet\nfrom plotly.figure_factory._candlestick import create_candlestick\nfrom plotly.figure_factory._dendrogram import create_dendrogram\nfrom plotly.figure_factory._distplot import create_distplot\nfrom plotly.figure_factory._facet_grid import create_facet_grid\nfrom plotly.figure_factory._gantt import create_gantt\nfrom plotly.figure_factory._ohlc import create_ohlc\nfrom plotly.figure_factory._quiver import create_quiver\nfrom plotly.figure_factory._scatterplot import create_scatterplotmatrix\nfrom plotly.figure_factory._streamline import create_streamline\nfrom plotly.figure_factory._table import create_table\nfrom plotly.figure_factory._trisurf import create_trisurf\nfrom plotly.figure_factory._violin import create_violin\n\nif optional_imports.get_module(\"pandas\") is not None:\n    from plotly.figure_factory._county_choropleth import create_choropleth\nelse:\n\n    def create_choropleth(*args, **kwargs):\n        raise ImportError(\"Please install pandas to use `create_choropleth`\")\n\n\nif optional_imports.get_module(\"skimage\") is not None:\n    from plotly.figure_factory._ternary_contour import create_ternary_contour\nelse:\n\n    def create_ternary_contour(*args, **kwargs):\n        raise ImportError(\"Please install scikit-image to use `create_ternary_contour`\")\n\n\n__all__ = [\n    \"create_2d_density\",\n    \"create_annotated_heatmap\",\n    \"create_bullet\",\n    \"create_candlestick\",\n    \"create_choropleth\",\n    \"create_dendrogram\",\n    \"create_distplot\",\n    \"create_facet_grid\",\n    \"create_gantt\",\n    \"create_ohlc\",\n    \"create_quiver\",\n    \"create_scatterplotmatrix\",\n    \"create_streamline\",\n    \"create_table\",\n    \"create_ternary_contour\",\n    \"create_trisurf\",\n    \"create_violin\",\n]\n", "path": "packages/python/plotly/plotly/figure_factory/__init__.py"}]}