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

ImportError: cannot import name 'FigureWidget' #130

Closed
mmrahn opened this issue Sep 10, 2018 · 18 comments
Closed

ImportError: cannot import name 'FigureWidget' #130

mmrahn opened this issue Sep 10, 2018 · 18 comments

Comments

@mmrahn
Copy link

mmrahn commented Sep 10, 2018

I just cloned the new cufflinks version 0.14.0 which is supposed to be compatible with plotly.
When trying to import cufflinks, I get the following error:

Traceback (most recent call last):
  File "C:\Users\monar\Miniconda3\envs\athion-utils\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-f6fce55a6101>", line 1, in <module>
    import cufflinks
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 19, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\monar\Miniconda3\envs\athion-utils\lib\site-packages\cufflinks\__init__.py", line 21, in <module>
    from .plotlytools import *
  File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.1.4\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 19, in do_import
    module = self._system_import(name, *args, **kwargs)
  File "C:\Users\monar\Miniconda3\envs\athion-utils\lib\site-packages\cufflinks\plotlytools.py", line 6, in <module>
    from plotly.graph_objs import Figure, Bar, Box, Scatter, FigureWidget, Scatter3d, Histogram, Heatmap, Surface, Pie
ImportError: cannot import name 'FigureWidget'

My plotly version is 3.1.1.

@santosjorge
Copy link
Owner

Hi @mmrahn -
Are you running this from a Jupyter Notebook / JupyterLab?
Can you run directly

from plotly.graph_objs import FigureWidget

?

@mmrahn
Copy link
Author

mmrahn commented Sep 11, 2018

No, I'm not using Jupyter. I'm running it from PyCharm (sometimes in an ipython console, sometimes with the regular python interpreter).

No, I can't:

from plotly.graph_objs import FigureWidget
Traceback (most recent call last):
  File "C:\Users\monar\Miniconda3\envs\clone-athion-utils\lib\site-packages\IPython\core\interactiveshell.py", line 2961, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-2-26cd651ce7af>", line 1, in <module>
    from plotly.graph_objs import FigureWidget
ImportError: cannot import name 'FigureWidget'

@mmrahn
Copy link
Author

mmrahn commented Sep 11, 2018

Okay, after a bit of digging, it turns out that FigureWidget cannot be imported because I didn't have ipywidgets installed. After installing it, I can both import FigureWidget and cufflinks.

Maybe add it to the requirements in setup.py?

@mmrahn
Copy link
Author

mmrahn commented Sep 11, 2018

Same goes for ipython btw: It is needed to import cufflinks but not included in the requirements.

@timkpaine
Copy link
Contributor

feel free to make a pull request

@timkpaine
Copy link
Contributor

#132

@santosjorge
Copy link
Owner

Thank you @timkpaine

@mmrahn
Copy link
Author

mmrahn commented Sep 13, 2018

@santosjorge I think this does not resolve the error because ipywidgets is still not added in the requirements.txt.
Minimal example:

conda create -n test python=3.6
conda activate test
pip install cufflinks~=0.14.1
ipython

import cufflinks

raises

ImportError: cannot import name 'FigureWidget'

@timkpaine
Copy link
Contributor

thats a transitive dependency through plotly

@timkpaine
Copy link
Contributor

meaning plotly should enforce it

@mmrahn
Copy link
Author

mmrahn commented Sep 13, 2018

@timkpaine Yes, but it doesn't seem to do it.

Sorry, I can't help you more because I'm not a python expert, but the example I posted would work if plotly indeed enforced it, wouldn't it?

@timkpaine
Copy link
Contributor

Yep, you should raise this issue with plotly directly

@colonelchlorine
Copy link

Looks like this could be an issue up there in Plotly: plotly/plotly.py#1111

What's strange is that I can skip cufflinks altogether and craft a Plotly graph from a Pandas DataFrame, so I just don't understand why cufflinks even needs ipywidgets to operate. Can you catch and then just skip it otherwise?

Anyone used Google Colaboratory and got this working in some way?

@timkpaine
Copy link
Contributor

Could, but there are reasons to not do that, namely the JavaScript paths are different between iplot and figurewidgrt. You should raise the issue with plotly

@mahmutkocak
Copy link

In colab I have the same issue!

@colonelchlorine
Copy link

@mahmutkocak With need for graphing in colab, I just switched to Altair. Mostly does the trick.

@liuyigh
Copy link

liuyigh commented Jan 14, 2019

If you installed ipywidgets and still did not work, FYI, I had to restart ipython console for newly installed ipywidgets to take effect.

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

6 participants