Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add informative error message when FigureWidget not available due to missing dependencies #1111

Closed
vlizanae opened this issue Aug 14, 2018 · 4 comments

Comments

@vlizanae
Copy link

I'm running an alpine python3 container and for some reason FigureWidget is not available. Jupyter is not installed because it's meant to be a Dash app, are there any dependencies I might have overlooked?
screenshot from 2018-08-14 17-56-03

@jonmmease
Copy link
Contributor

Hi @vlizanae ,

The FigureWidget class won't be available unless ipywidgets is installed. If you're making a Dash app, then you'll want to use the graph_objs.Figure class instead of FigureWidget. FigureWidget is essentially a subclass of Figure with extra logic and dependencies for integrating with the Jupyter Notebook.

Thanks for reporting this because it reminds me that it would be nice to do something more user friendly when someone tries to access a FigureWidget when the dependencies aren't available.

Alright if I change the title of this issue to "Raise informative error if FigureWidget dependencies are not installed"?

@vlizanae
Copy link
Author

sure, thank you!

@jonmmease jonmmease changed the title FigureWidget not available Add informative error message when FigureWidget not available due to missing dependencies Aug 18, 2018
@astrojuanlu
Copy link
Contributor

I was thinking about this a bit and I don't see a quick & straightforward solution. This is the way FigureWidget is being imported in the graph_objs namespace:

try:
    import ipywidgets
    from distutils.version import LooseVersion
    if LooseVersion(ipywidgets.__version__) >= LooseVersion('7.0.0'):
        from ._figurewidget import FigureWidget
    del LooseVersion
    del ipywidgets
except ImportError:
    pass

The only options I see:

  • Keep this code, but instead of silencing the ImportError, display a warning. The problem is that lots of users that are not interested in FigureWidgets will see it.
  • Do not import it in graph_objs, and instead make the user do from plotly.graph_objs.widgets import FigureWidget. This is an API breaking change, and also annoying to have this object in a different module.
  • Add ipywidgets>7 to the plotly.py requirements and get rid of the conditional import altogether.

Other ideas?

astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Jun 10, 2019
Fix poliastro#629.
For a better error message when ipywidgets is missing,
see plotly/plotly.py#1111
astrojuanlu added a commit to astrojuanlu/poliastro that referenced this issue Jun 10, 2019
Fix poliastro#629.
For a better error message when ipywidgets is missing,
see plotly/plotly.py#1111
Sedictious pushed a commit to Sedictious/poliastro that referenced this issue Jun 25, 2019
Fix poliastro#629.
For a better error message when ipywidgets is missing,
see plotly/plotly.py#1111
@nicolaskruchten
Copy link
Contributor

Closed by #2445

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants