Reputation: 976
I created a table with an interactive slider that allows me to toggle between different periods on my table. It was working for the past few days, until today, when I re-ran the notebook, the slide bar doesn't show anymore. No error messages appear. The code seem to run just fine, as the table appears, but the slide bar just doesn't appear. I didn't change my code either, as I was working on a separate part of my notebook.
I tried many approaches, including searching in this space but was still unable to come up with a solution. I was wondering if anyone faced a similar issue, and have any solution to this.
Below is my code snippet. Anything before was solely to get my data into the desired form for tabulation.
from IPython.display import display
from ipywidgets import widgets, interactive
v = interactive(by_q, quarter=(['q1y2015', 'q2y2015', 'q3y2015', 'q4y2015']), days=(1, 180))
display(v)
Upvotes: 79
Views: 130248
Reputation: 731
To all the folks coming from jupyterlab
Jupyter 3.0 and higher
Also check the docs, but:
conda install -n base -c conda-forge jupyterlab_widgets
conda install -n pyenv -c conda-forge ipywidgets
Jupyter 1 or 2
Please check steps to make it work in Jupyter 1 or 2 docs
After this restart or build the lab to see the changes
Upvotes: 2
Reputation: 161
For anyone still stumped after the accepted suggestions, the answer might be simple: There's a Jupyter Lab prompt to enable extensions on the Extension Manager tab (in the left panel). I did all kinds of installation steps for the python environment, but in the end I just wasn't allowing Jupyter Lab to run them apparently.
Upvotes: 4
Reputation: 1
I had similar problem while working in chrome. But when I open a same notebook in different browser (internet explorer) it is showing all the widgets just fine. Copy the url from jupyter notebook and open it in another browser, it will work.
Not sure why this is happening looking forward for help.
Upvotes: 0
Reputation: 1846
After googling for a while without hope, I realized that I needed
jupyter labextension install @jupyter-widgets/jupyterlab-manager
Upvotes: 45
Reputation: 211
Even though this is 6 years old, this is what worked for me. Even after using Elaine's question.
After running jupyter --version
inside my conda environment, i saw this.
$ jupyter --version
Selected Jupyter core packages...
IPython : 8.4.0
ipykernel : 6.9.1
ipywidgets : 7.7.1
jupyter_client : 7.2.2
jupyter_core : 4.10.0
jupyter_server : not installed
jupyterlab : not installed
nbclient : 0.6.4
nbconvert : 6.5.0
nbformat : 5.4.0
notebook : 6.4.12
qtconsole : not installed
traitlets : 5.4.0
So i ran:
pip install jupyterlab
pip install jupyter_server
After restarting my kernel, the widgets appeared just fine.
I hope this helps someone looking for this question, just as i did.
Upvotes: 1
Reputation: 1488
With the new version of ipywidgets
, I ran into this problem, but then I found on their github readme that you now need to follow
pip install ipywidgets
with
jupyter nbextension enable --py widgetsnbextension
Note: To those using virtual environments (including conda environments) the recommended way to activate the extension is to run
jupyter nbextension enable --py --sys-prefix widgetsnbextension
That cleared the problem up for me.
Upvotes: 130
Reputation: 1109
Apparently, if you are trying to use it on the virtual environment and running on vscode , then jupyter notebook itself doesn't work that efficiently but it works on using ipython <notebook_name>
, but in that case you won't be able to visualize widgets. So the best way is to do jupyter notebook <notebook name>
, which will open notebook on chrome, and then change the kernel first, i.e. choose your virtual environment and run on the chrome.
Upvotes: 0
Reputation: 2088
Adding to Alexander Svetly's answer, running:
jupyter labextension install @jupyter-widgets/jupyterlab-manager
seemed to get stuck, by adding --debug I was able to see where:
jupyter labextension install --debug @jupyter-widgets/jupyterlab-manager
[...]
npm notice 📦 @jupyter-widgets/[email protected]
[...]
Fetching URL: https://registry.yarnpkg.com/@jupyter-widgets%2Fjupyterlab-manager
Looks like it's trying to install version 3 but I am using version 2.2.9 of Jupyter Lab, so what finally worked was:
jupyter nbextension enable --py widgetsnbextension --sys-prefix
jupyter labextension install --debug @jupyter-widgets/[email protected]
Upvotes: 4
Reputation: 8168
If you've already got [an older version] of ipywidgets
installed in Jupyter and you're seeing this problem (you'll probably be seeing javascript errors in the browser console) then you need to run the install
command to update the relevant files e.g.:
jupyter nbextension install --user --py widgetsnbextension
And you may also need to rerun the enable
command e.g.:
jupyter nbextension enable --user --py widgetsnbextension
Note: the --user
argument may need to be different if you're using a virtualenv or other environment - see the ipywidget docs for more details.
Upvotes: 11
Reputation: 2454
Might have been a stupid mistake of mine, but in case you are using virtual environments, just keep properly in mind what is running from where.
You might properly run Jupyter from inside your current environment every time as needed, or might have a root env from which you always start the Jupyter you will end up using for all your environments.
For the latter case, what you need to be sure is to enable nbextension for the Jupyter you are actually running, instead of mistakenly run the command from within your currently active environment.
Upvotes: 3
Reputation: 1345
I think plot.ly imports a function called display
which overrides the function display
from ipython. Try changing the order of imports or simply import the function under a different name
Upvotes: 2