FigureWidget doesn't print graph

Hi All,

I have been using plotly for a while and it worked great until i had to use FigureWidget to interact with mouse events.

The following code doesn’t output anything:

import plotly.graph_objects as go

f = go.FigureWidget()
f

while this code ‘w/ the .show()’ works and i could see the graph:

import plotly.graph_objects as go

f = go.FigureWidget()

f.show()

I tried on Windows and Linux, from terminal or from Jupyter notebook … i also matched my version with the version on github as suggested inthis thread … i even created a new anaconda environment from scratch but nothing helped.

i noticed others are also running into this issue here.

i’m putting my pip list output below, if you can help i will be thankful as i spent hours without finding a solution.

Package Version


aiohttp 3.5.4
arrow 0.14.6
asn1crypto 0.24.0
astroid 2.2.5
async-timeout 3.0.1
atomicwrites 1.3.0
attrs 19.1.0
autobahn 19.9.2
Automat 0.7.0
backcall 0.1.0
base58 0.2.2
binance-dex 0.1.3
bleach 3.1.0
certifi 2019.11.28
cffi 1.12.3
chardet 3.0.4
click 6.6
coincurve 12.0.0
colorama 0.4.1
constantly 15.1.0
cryptography 2.7
cycler 0.10.0
cytoolz 0.10.0
dash 1.2.0
dash-core-components 1.1.2
dash-daq 0.1.7
dash-html-components 1.0.1
dash-renderer 1.0.1
dash-table 4.2.0
dateparser 0.7.1
decorator 4.4.0
defusedxml 0.6.0
docker-py 1.8.0
ecdsa 0.13.2
electrumsv-secp256k1 0.9.1
entrypoints 0.3
eth-hash 0.2.0
eth-typing 2.1.0
eth-utils 1.4.1
flake8 3.7.8
Flask 1.1.1
Flask-Compress 1.4.0
foil 0.2.7
funcsigs 1.0.2
future 0.17.1
hyperlink 19.0.0
idna 2.8
importlib-metadata 0.19
incremental 17.5.0
inflection 0.3.1
ipykernel 5.1.1
ipython 7.6.1
ipython-genutils 0.2.0
ipywidgets 7.5.1
iso8601 0.1.12
isort 4.3.21
itsdangerous 1.1.0
jedi 0.13.3
Jinja2 2.10.1
json5 0.8.5
jsonrpcclient 2.0.1
jsonrpcserver 3.1.1
jsonschema 3.0.1
jupyter 1.0.0
jupyter-client 5.3.4
jupyter-console 6.0.0
jupyter-core 4.6.1
jupyterlab 1.2.3
jupyterlab-server 1.0.6
kiwisolver 1.1.0
lazy-object-proxy 1.4.1
MarkupSafe 1.1.1
matplotlib 3.1.0
mccabe 0.6.1
mistune 0.8.4
mkl-fft 1.0.12
mkl-random 1.0.2
mkl-service 2.0.2
mnemonic 0.18
more-itertools 7.0.0
multidict 4.5.2
nb-conda 2.2.1
nb-conda-kernels 2.2.2
nbconvert 5.5.0
nbformat 4.4.0
notebook 6.0.1
numpy 1.16.4
packaging 19.1
pandas 0.24.2
pandocfilters 1.4.2
parso 0.5.0
path.py 12.0.1
patsy 0.5.1
pbkdf2 1.3
pexpect 4.7.0
pickleshare 0.7.5
pip 19.1.1
pkgconfig 1.5.1
plotly 4.3.0
plotly-geo 1.0.0
pluggy 0.12.0
prometheus-client 0.7.1
prompt-toolkit 2.0.9
protobuf 3.6.1
psutil 5.6.3
ptyprocess 0.6.0
py 1.8.0
pyaes 1.6.1
pyasn1 0.4.7
pyasn1-modules 0.2.6
pycodestyle 2.5.0
pycparser 2.19
pycrypto 2.6.1
pycryptodome 3.8.0
pyflakes 2.1.1
Pygments 2.4.2
PyHamcrest 1.9.0
pylint 2.3.1
pyOpenSSL 19.0.0
pyparsing 2.4.2
pyrsistent 0.14.11
PySocks 1.7.0
pytest 5.1.2
python-binance 0.7.3
python-dateutil 2.8.0
pytz 2019.1
pywallet 0.1.0
pywin32 227
pywinpty 0.5.5
PyYAML 5.1.2
pyzmq 18.0.0
qtconsole 4.5.2
Quandl 3.4.5
regex 2019.8.19
requests 2.11.1
retrying 1.3.3
rlp 1.1.0
scipy 1.3.0
Send2Trash 1.5.0
service-identity 18.1.0
setuptools 41.0.1
sha256 0.1
six 1.12.0
statsmodels 0.10.1
tabulate 0.8.3
terminado 0.8.2
testpath 0.4.2
toolz 0.10.0
tornado 6.0.3
traitlets 4.3.2
Twisted 19.7.0
two1 3.10.9
txaio 18.8.1
tzlocal 2.0.0
ujson 1.35
urllib3 1.24.2
wcwidth 0.1.7
webencodings 0.5.1
websocket-client 0.56.0
websocket-client-py3 0.15.0
websockets 8.0.2
Werkzeug 0.15.5
wheel 0.33.4
widgetsnbextension 3.5.0
win-inet-pton 1.1.0
wincertstore 0.2
wrapt 1.11.2
yarl 1.3.0
zipp 0.6.0
zope.interface 4.6.0

Hi @abdoos I had the same problem a while ago, the problem for me was that the widgets extension had not been enabled correctly (as I could check from executing jupyter nbextension list, the output was empty). If it’s empty can you try

jupyter nbextension enable --py widgetsnbextension

(or,

jupyter nbextension enable --py widgetsnbextension --sys-prefix

in your conda env
see https://jupyter-notebook.readthedocs.io/en/4.x/examples/Notebook/rstversions/Distributing%20Jupyter%20Extensions%20as%20Python%20Packages.html#enable-nbextension-assets). Hope this helps!

1 Like

Hi @Emmanuelle, Thanks for the suggestion.

I tried both and it supposedly enabled the extension, but still no luck.

Enabling notebook extension jupyter-js-widgets/extension...
      - Validating: ok

jupyter nbextension list returns this:

Known nbextensions:
  config dir: C:\Users\C43071\.jupyter\nbconfig
    notebook section
      jupyter-js-widgets/extension enabled
      - Validating: ok
  config dir: C:\Users\C43071\AppData\Local\Continuum\anaconda3\envs\Tech-Analysis\etc\jupyter\nbconfig
    notebook section
      plotlywidget/extension enabled
      - Validating: ok
      nb_conda/main enabled
      - Validating: ok
      nglview-js-widgets/extension enabled
      - Validating: ok
      jupyter-js-widgets/extension enabled
      - Validating: ok
    tree section
      nb_conda/tree enabled
      - Validating: ok

Upon restarting jupyter i noticed this message though.

A Jupyter widget could not be displayed because the widget state could not be found. This could happen if the kernel storing the widget is no longer available, or if the widget state was not saved in the notebook. You may be able to create the widget by running the appropriate cells

i tried ipywidget generic hello world and slider examples “w/o plotly” and they work ok, but once i add plotly code they also stop appearing.

If you notice something or have any other idea i will be thankful.

Thanks!

Wow this is weird. I guess you also tried to open a completely new notebook after you enabled the extension? Please open an issue on https://github.com/plotly/plotly.py/issues/new pasting the different elements we’ve discussed here, because it sounds like a bug or at least something which should not happen.

Hi @Emmanuelle, yes of course i restarted the whole PC.

However, i was able to make progress. i found out that if you actually open a Jupyter lab by running the command “jupyter lab” and then run the code there, it works and shows the graph. the same code under jupyter notebook “running the notebook app” or by running vanilla python with the browser as renderer didn’t work. (even if it works for non figurewidget)

I’m not sure why this is happening or wither it’s the expected behavior or not as it’s not described anywhere but glad it’s somehow working now.

Thanks alot!

Well I’m glad you found a solution @abdoos but it still does not behave as expected!

I am also having this problem. I am just getting started with plotly so I don’t know enough to ask questions intelligently, and also my novice status makes it especially confusing when the documentation examples don’t work.

I am just trying to get a python script to run, create a graph, display the graph, stay running, update the data on the graph in a way that actually gets displayed, and still stay running.

Is there an example python script somewhere that does this?

Many examples seem to be intended for interactive use. I want to write python programs that work using plotly (i.e., scripts I can run, not scenarios where I have to type into the python CLI), and when something doesn’t work I can’t tell whether it’s because the libraries are broken or because it’s only intended to work interactively.

I’d welcome a pointer to some python scripts that can serve as examples for the kind of thing I’m trying to do. Many thanks!

Also, is there a bug filed somewhere about the silent failure described in this thread? Is anyone trying to fix it? I gather from the messages in the thread so far that it’s not working as intended.

Apparently there is version magic required – the system fails to detect mismatched versions of things that depend on each other. That’s one bug. Is it fixed already, or being worked on?

And then apparently (IIUC) even if all the versions match, the system doesn’t work for some reason. That’s another bug, I think, and I wonder if someone’s working on that.

1 Like

Hi Robert,

Let me save you a ton of time. the only way to achieve what you want is to use jupyter lab or use plotly library called dash. The normal python interpreter will not run plotly figure widget as the server is dead after it plots the figure. also, ipywidget which figure widget depend on seem to be a thing of ipython, not python.

take a look at the dash gallery: https://dash-gallery.plotly.host/Portal/

of course i might be wrong. but that’s my conclusion to date.

good luck!