When creating an input cell on a jupyter notebook that displays an ipywidget and marking this cell as Initialization cell, the widget is rendered twice on my machine.
See the following example:
from ipywidgets import widgets
from IPython.display import display
def print_hello(b=None):
print("hello")
my_button = widgets.Button(description="press it")
my_button.on_click(print_hello)
display(my_button)
However it seems to work correctly when no widgets are involved:
def f(x):
return x + 3
print(f(5))

Maybe @jcb91 could have a look at this?
Tested with
Having the same setup, don't have the problem in the older Firefox ESR 52.3.0 (64-bit) on Debian 9.1 (stretch)
Tried again with chromium 60.0.3112.78 running on Ubuntu.16.04 and it seems to be working correctly there as well.
I downloaded a Firefox 55.0.1 (64bit) for Linux and also can't reproduce it there. Any Firefox Extensions/Plugins you have installed?
apologies for the delay looking at this @codingS3b. So far, this seems to be working ok for me in Chrome 59.0.3071.115 (Official Build) (64-bit) and FF 55.0.2 (64-bit) on Ubuntu 16.0.4...
Also, what's your jupyter notebook --version?
Concerning plugins I use Adblock Plus but disabled it for testing and the google analytics deactivation add-on but that's it.
My jupyer notebook version is 5.0.0.
I also tried this again using Chromium 60.0.3112.78 on Ubuntu 16.04 and got the same behaviour as with firefox.
I have to add that the widgets are rendered correctly sometimes I refresh the notebook using F5 but sometimes not. Strange thing...
I have the same problem as codingS3b .. widgets appear twice when executed by an initialization cell
I'm still unable to reproduce this. Combined with the intermittent observations, this leads me to suspect a timing issue, maybe some race condition somewhere. @BarbaraPr what versions of everything are you running?
Are all of you running the server on the same machine as the browser, or is the notebook server running on a remote machine?
I have now tried both versions with firefox and chromium, here are my experiences:
Chromium:
Firefox:
Would a screenshot from the browser debugging section help you in some way?
Thanks @codingS3b, so from that it seems like _maybe_ this issue is more likely to trigger when the notebook is loaded quickly (I asked about local/remote servers because in the past I've found that the extra time required to get the notebook from the remote server can affect timing-related bugs).
Would a screenshot from the browser debugging section help you in some way?
I'm not sure, really :laughing: I'm still at a loss for what could cause this. However, I suspect this has more to do with how widgets are implemented (somehow the cell clearing its outputs on execution is not happening correctly?!) than with init_cell, which after all just queues the cells for regular execution :thinking:
I had same issue when running notebook on ec2 GPU instance.
I had same notebook running on localhost too and synced through dropbox.
so I shutdown the notebook on remote ec2 instance. Then I shut down same notebook on localhost. Then restarted it on ec2 only, and it worked.
Most helpful comment
Concerning plugins I use Adblock Plus but disabled it for testing and the google analytics deactivation add-on but that's it.
My jupyer notebook version is 5.0.0.
I also tried this again using Chromium 60.0.3112.78 on Ubuntu 16.04 and got the same behaviour as with firefox.
I have to add that the widgets are rendered correctly sometimes I refresh the notebook using F5 but sometimes not. Strange thing...