Issue
I have a problem that interactive objects from ipywidgets
do not work in Jupyter Notebook on my computer. The widget itself is displayed but the function that it should control (e.g. drawing graph with changing parameter), seemingly, does not run. I took example from documentation and it does not work.
The picture of code and output
Code:
import ipywidgets
import widgetsnbextension
def greeting(text="World"):
print("Hello {}".format(text))
ipywidgets.interact(greeting, text="IPython Widgets")
What have I already tried:
- There were similar questions, like this but the answer didn't work for me (the answer was to run this:
jupyter nbextension enable --py widgetsnbextension
). - The code above works in GoogleColab so I tried to install their versions of packages
ipython
andipykernel
(packagesipywidgets
andwidgetsnbextensions
were of the same version as mine). But it has led to errors so I have given up this idea. I have the latest versions of all packages now and I don't have Anaconda.
What should I try next? May be I am wrong and the problem has a different cause?
Solution
I found the answer!!!
I have had several nbextensions
switched on (see screenshot). This was my mistake to include everything which seemed useful. When I turned off all nbextensions
then all ipywidgets
stuff started to work. Finally, I found that one particular extension called Limit Output is to be blamed for. Turn it off and all works fine.
The moral: don't use everything if you don't need it. Also, obviously, there is a bug in Limit Output extension because it is not supposed to affect widgets (it is supposed to limit output data when you accidentally write while(true)
or something like that).
You can read some useful stuff about SageMath in the comments under the original question as well.
Answered By - appleivanko
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.