jupyter-widgets / ipywidgets

Interactive Widgets for the Jupyter Notebook
https://ipywidgets.readthedocs.io
BSD 3-Clause "New" or "Revised" License
3.14k stars 949 forks source link

Widget Javascript not detected #541

Closed rafaelobraun closed 8 years ago

rafaelobraun commented 8 years ago

After the update from ipywidgets (5.1.0) and widgetsnbextension (1.1.0) an error occurr with my Jupyter notebooks: [IPKernelApp] WARNING | Widget Javascript not detected. It may not be installed properly.

Thanks

Rafael

jasongrout commented 8 years ago

Did you enable the widgetsnbextension? You need to do

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

It mentions this in the readme to ipywidgets, but it doesn't say anything on the pypi page, and maybe it doesn't say it when you install? We're working on making this part automatic, but it's not automatic yet.

@SylvainCorlay, can we update the pypi long description to mention this, and also make the setup.py explicitly print this step when installing, if it doesn't do that now? At least until we get this step to be automatic?

rafaelobraun commented 8 years ago

It works with Jupyter Notebooks, but now it don't works with Jupyterhub. Is the configuration different?

Thanks.

hainm commented 8 years ago

@jasongrout can you point me to the doc to say why users need to

jupyter nbextension enable --py --sys-prefix widgetsnbextension. thanks. (What's benefit of asking users to do that). We are working on a protein viewer in notebook and this new behavior caused me much trouble (I don't know why until reading this issue).

updated

I've just read your comment above. Sorry for not reading thoroughly.

We're working on making this part automatic, but it's not automatic yet

rafaelobraun commented 8 years ago

Now it works with the new version on Jupyterhub too. Thanks. Rafael ipywidgets 5.1.3 widgetsnbextension 1.2.2

jasongrout commented 8 years ago

@hainm: https://github.com/ipython/ipywidgets/blob/master/README.md#install is where it says you have to enable the wigetsnbextension (currently).

akochepasov commented 8 years ago

The actual documentation helped me. This should fix the problem: jupyter nbextension enable --py widgetsnbextension However since I use macports, I have to fix it slightly different: jupyter-nbextension-2.7 enable --py widgetsnbextension

cardosan commented 8 years ago

I have this same issue but also enabling the extension jupyter nbextension enable --py --sys-prefix widgetsnbextension nothing and the dependencies seems to be meet.

` $ conda list

backports 1.0 py35_0 defaults backports.shutil-get-terminal-size 1.0.0 backports.shutil_get_terminal_size 1.0.0 py35_0 conda-forge colorlover 0.2.1 cufflinks 0.7.2 cycler 0.10.0 py35_0 defaults decorator 4.0.9 py35_0 defaults entrypoints 0.2 py35_1 defaults fontconfig 2.11.1 5 defaults freetype 2.5.5 0 defaults get_terminal_size 1.0.0 py35_0 defaults ipykernel 4.3.1 py35_0 defaults ipython 4.2.0 py35_0 defaults ipython-genutils 0.1.0 ipython_genutils 0.1.0 py35_0 defaults ipywidgets 5.1.5 py35_0 conda-forge jinja2 2.8 py35_0 defaults jsonschema 2.4.0 py35_0 defaults jupyter 1.0.0 py35_3 defaults jupyter-client 4.2.2 jupyter-console 4.1.1 jupyter-core 4.1.0 jupyter_client 4.2.2 py35_0 defaults jupyter_console 4.1.1 py35_0 defaults jupyter_core 4.1.0 py35_0 defaults libpng 1.6.17 0 defaults libsodium 1.0.3 0 defaults libxml2 2.9.2 0 defaults markupsafe 0.23 py35_0 defaults matplotlib 1.5.1 np111py35_0 defaults mistune 0.7.2 py35_0 defaults mkl 11.3.1 0 defaults natsort 4.0.4 nbconvert 4.2.0 py35_0 defaults nbformat 4.0.1 py35_0 defaults ncurses 5.9 7 conda-forge networkx 1.11 notebook 4.2.0 py35_0 defaults numpy 1.11.0 py35_0 defaults openssl 1.0.2g 0 defaults pandas 0.18.1 np111py35_0 defaults path.py 8.2.1 py35_0 defaults pexpect 4.0.1 py35_0 defaults pickleshare 0.5 py35_0 defaults pip 8.1.1 py35_1 defaults plotly 1.12.0 ptyprocess 0.5 py35_0 defaults pygments 2.1.3 py35_0 defaults pyparsing 2.1.1 py35_0 defaults pyqt 4.11.4 py35_1 defaults python 3.5.1 0 defaults python-dateutil 2.5.2 py35_0 defaults pytz 2016.3 py35_0 defaults pyzmq 15.2.0 py35_0 defaults qgrid 0.3.2 qt 4.8.7 1 defaults qtconsole 4.2.1 py35_0 defaults readline 6.2 2 defaults requests 2.10.0 rpy2 2.7.8 scipy 0.17.0 seaborn 0.7.0 setuptools 20.7.0 py35_0 defaults simplegeneric 0.8.1 py35_0 defaults sip 4.16.9 py35_0 defaults six 1.10.0 py35_0 defaults sqlite 3.9.2 0 defaults terminado 0.5 py35_1 defaults tk 8.5.18 0 defaults tornado 4.3 py35_0 defaults traitlets 4.2.1 py35_0 defaults wheel 0.29.0 py35_0 defaults widgetsnbextension 1.2.3 py35_1 conda-forge xlrd 0.9.4 xlwt 1.0.0 xz 5.0.5 1 defaults zeromq 4.1.3 0 defaults zlib 1.2.8 0 defaults ` any idea?

jasongrout commented 8 years ago

@cardosan - can you open a new issue and post the results of jupyter nbextension list there?

cardosan commented 8 years ago

HI Jason, while writing the issue I realized that now (very strange) without changing anything is working...maybe needed simply to reboot. Thanks G

jasongrout commented 8 years ago

Great!

ostrokach commented 7 years ago

For some reason, on Anaconda Python 3.6, running:

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

did not work for me, but:

jupyter nbextension enable --py

did!

Maybe it's worth elaborating on this in the documentation?

michaelaye commented 7 years ago

You meant jupyter nbextension enable --py widgetsnbextension

jasongrout commented 7 years ago

Maybe it's worth elaborating on this in the documentation?

I highly recommend that people use --sys-prefix (and figure out why that didn't work), rather than using the personal location without --sys-prefix. It sounds like @ostrokach had widgets installed in the personal location rather than the sys-prefix location. I think it would be better to delete widgets out of the personal location

michaelaye commented 7 years ago

But I always see the sys-prefix option recommended to be removed for conda users? Are you saying that's all wrong?

jasongrout commented 7 years ago

I recommend the --sys-prefix option especially for conda users. I think it's the only way to easily keep things consistent and sane. That keeps the installed software consistent with the environment you are in. Otherwise, it's easy to get into the situation where you have one version of a package javascript installed in your personal directory used with an environment with a totally different version of the python package.

jasongrout commented 7 years ago

To be clear, this illustrates the huge problem with not using --sys-prefix with conda:

  1. A user is in environment A. They install widgetsnbextension and then do jupyter nbextension install --py widgetsnbextension. This installs the javascript into their home directory, not tied to any environment. They also enable the extension in their home directory.
  2. The user switches to a different environment where they have a different ipywidgets and widgetsnbextension installed that is incompatible with the version in (1). Things won't work, since they have the nbextension from the wrong package installed. So they maybe install it again, but that just overwrites the nbextension (if they remember to do something like --overwrite), and sets up the same problem for a different environment.

I think it's much better to install to --sys-prefix, so the extension and the enabling is constrained to the environment you have activated. You switch to a new environment, and you have a fresh clean slate.

michaelaye commented 7 years ago

Thanks so much. I think I got that completely inverse before you explained it. Just one more thing, I saw one of these writing into my user Library on the Mac, is that what you mean with user's home? For example, right now I have the Jupyter extensions complaining at start up that they have definition files twice, I guess because I switched between different options s at some stage.

jasongrout commented 7 years ago

You can do jupyter --paths to see where the various files would go. The first lines are the personal locations, followed by the sys-prefix locations, followed by system locations. For me, the personal files do go into my Library directory on OS X.

jasongrout commented 7 years ago

Personally I regularly completely delete my user-level config, and rely solely on sys-prefix.

bayoglur commented 7 years ago

Hello. I just installed Anaconda Python 3.6 version on Windows 7, and I got the same error. I implemented this command (jupyter nbextension enable --py --sys-prefix widgetsnbextension) on the Anaconda Prompt, but the problem is still there. I also tried running jupyter nbextension enable --py widgetsnbextension, but no success. I tried several times installing, uninstalling, rebooting etc. Could someone help me on this please?

Note: When I run Jupyter Notebook, I get this:

file
bayoglur commented 7 years ago

@jasongrout Could you please help?

davidedelvento commented 7 years ago

@rafaelobraun Can you please edit your comment and write how does it work in jupyterhub? I can't find any way to make it work, so much so that I opened a issue with jupyterhub itself https://github.com/jupyterhub/jupyterhub/issues/1113

marscher commented 7 years ago

I'm struggling to get this to work for the jupyter nbconvert command on a remote machine. Locally it works tough. I have a separate conda env running, so I used --sys-prefix for the command. The extension is being listed as enabled, however I still get those error messages.

  1. jupyter nbextension install widgetsnbextension --py --sys-prefix
  2. jupyter nbextension enable widgetsnbextension --py --sys-prefix

env.txt

Any help would be really appreciated.

stolsvik commented 7 years ago

When you run that jupyter nbextension enable --py --sys-prefix widgetsnbextension, do you do that within or outside of some conda environment (that is, have you "activated" the environment or not)? Nobody seems to mention this, does it even matter? I've install that "nb_conda" thing to get virtual environments inside jupyter notebook - and I always start jupyter notebook in "root" (i.e. not having activated any virtual environment), instead specifying environment within jupyter notebook. Which is great.

If it isn't obvious, I have no clue of what I am talking about - but after getting this to work after 45 minutes of banging my head on the keyboard, I still don't know where and how I installed or enabled that freakin' widgetsnbextension. Which isn't very satisfying.

stolsvik commented 7 years ago

One more thing: Does "enable" imply "install", or should you do install, then enable? For me, this might have made a difference..

jasongrout commented 7 years ago

The enable command needs to be run in the same environment as the notebook is running. If you start the notebook from the root environment, then that's where you need to do the enable command.

Enable doesn't imply install. However, installing the widgetsnbextension python package automatically installs the notebook extension in the same environment.

On Fri, Jun 30, 2017, 16:26 stolsvik notifications@github.com wrote:

One more thing: Does "enable" imply "install", or should you do install, then enable? For me, this might have made a difference..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/jupyter-widgets/ipywidgets/issues/541#issuecomment-312365262, or mute the thread https://github.com/notifications/unsubscribe-auth/AALwZg4-0rPr0lZaR17zKZTJHyc5xgpKks5sJVnhgaJpZM4IRwca .

Winghin2517 commented 7 years ago

I had this problem on mac so I solved it by:

  1. source activate myenv
  2. running this command in myenv: jupyter nbextension enable --py --sys-prefix widgetsnbextension
  3. Restarting my kernel.

The error went away after that.

tsbertalan commented 7 years ago

This is a recurring issue for me, probably because I have some user config files, and do switch between a few virtual environments (not conda environments). The command with --sys-prefix doesn't get rid of the "widget javascript not detected" warning, but the command without does -- at least temporarily. At the moment, I'm not able to reproduce the warning by switching between virtual environments and running jupyter notebook on each (with a small test notebook that uses tqdm.tqdm_notebook), but I am able to reproduce it with a more complicated real notebook. (Additionally using a %matplotlib inline magic to the test notebook doesn't trigger it there either, though it does appear to happen in that notebook after I've run the more complicated one to the point where it uses tqdm and triggers the warning.)

As @jasongrout mentioned, I might want to delete some user config files, after which the command with --sys-prefix might work. However, I'm not sure what to delete. I have a ~/.jupyter/jupyter_notebook_config.py file that contains, most importantly, a hashed password that I want to keep using. Running jupyter --paths with the environment venv3 activated gives this output:

config:
    /home/tsbertalan/.jupyter
    /home/tsbertalan/venv3/etc/jupyter
    /usr/local/etc/jupyter
    /etc/jupyter
data:
    /home/tsbertalan/.local/share/jupyter
    /home/tsbertalan/venv3/share/jupyter
    /usr/local/share/jupyter
    /usr/share/jupyter
runtime:
    /run/user/1000/jupyter

However, /home/tsbertalan/venv3/share/jupyter does not contain a jupyter_notebook_config.py file.

Is it only ~/.jupyter/nbconfig/notebook.json that I would delete (which has no important differences from ~/venv3/etc/jupyter/nbconfig/notebook.json)? Are there perhaps packages that I'd need to reinstall with pip in the environment(s)? Are the extensions being "activated" something separate from simple python packages, which I perhaps also would want to delete from somewhere in ~/.jupyter? Deleting ~/.jupyter/nbconfig/notebook.json before running the --sys-prefix command doesn't seem to kill the warning. Only running the command without the extra flag does, and even then not always--I'm not sure when.

blink1073 commented 7 years ago

@tsbertalan, have you checked /home/tsbertalan/.local/share/jupyter? I had overlooked that folder myself previously and removing it cleared this problem.

tsbertalan commented 7 years ago

Thanks, @blink1073 . If I rename that folder and then run jupyter nbextension enable --py --sys-prefix widgetsnbextension in the virtualenv, I still get the warning. If I deactivate the environment and run the command again, I get IOError: [Errno 13] Permission denied: u'/usr/etc/jupyter/nbconfig/notebook.json' Do any of you know whether I should I be running it out of virtualenv as root? I expect the answer is no.

tsbertalan commented 7 years ago

Huh. Maybe I spoke too soon. I ran the command one more time in the virtualenv, deactivated and reactivated it, and started my notebook, and now the warning seems to be gone. I guess if it comes back, I'll complain here.

wnowak10 commented 6 years ago

FYI -- I struggled for a while with this, and then ran the install steps outside of my conda virtual environment and it finally worked.

boisgera commented 6 years ago

I have the same issue (widgets not detected) with jupyter notebooks in binder.

See https://github.com/boisgera/tmp-notebook for the setup (Python 2.7; AFAICT Python 3.x works fine).

Launch the notebook with: Binder

Configuration:

$ conda list

# packages in environment at /srv/conda:
#
asn1crypto                0.22.0           py36h265ca7c_1    defaults
bleach                    2.0.0                    py36_0    conda-forge
ca-certificates           2017.11.5                     0    conda-forge
certifi                   2017.11.5                py36_0    conda-forge
cffi                      1.10.0           py36had8d393_1    defaults
chardet                   3.0.4            py36h0f667ec_1    defaults
conda                     4.3.30           py36h5d9f9f4_0    defaults
conda-env                 2.6.0                h36134e3_1    defaults
cryptography              2.0.3            py36ha225213_1    defaults
decorator                 4.1.2                    py36_0    conda-forge
entrypoints               0.2.3                    py36_1    conda-forge
gmp                       6.1.2                         0    conda-forge
html5lib                  1.0.1                      py_0    conda-forge
idna                      2.6              py36h82fb2a8_1    defaults
ipykernel                 4.7.0                    py36_0    conda-forge
ipython                   6.2.1                    py36_1    conda-forge
ipython_genutils          0.2.0                    py36_0    conda-forge
ipywidgets                6.0.1                    py36_0    conda-forge
jedi                      0.10.2                   py36_0    conda-forge
jinja2                    2.10                     py36_0    conda-forge
jsonschema                2.6.0                    py36_0    conda-forge
jupyter_client            5.2.1                    py36_0    conda-forge
jupyter_core              4.4.0                      py_0    conda-forge
jupyterlab                0.30.6                   py36_0    conda-forge
jupyterlab_launcher       0.6.0                    py36_0    conda-forge
libedit                   3.1.20170329                  0    conda-forge
libffi                    3.2.1                h4deb6c0_3    defaults
libgcc-ng                 7.2.0                h7cc24e2_2    defaults
libsodium                 1.0.15                        1    conda-forge
libstdcxx-ng              7.2.0                h7a57d05_2    defaults
markupsafe                1.0                      py36_0    conda-forge
mistune                   0.8.3                      py_0    conda-forge
nbconvert                 5.3.1                      py_1    conda-forge
nbformat                  4.4.0                    py36_0    conda-forge
ncurses                   5.9                          10    conda-forge
notebook                  5.2.2                    py36_1    conda-forge
openssl                   1.0.2n                        0    conda-forge
pandoc                    2.1                           0    conda-forge
pandocfilters             1.4.1                    py36_0    conda-forge
pexpect                   4.3.1                    py36_0    conda-forge
pickleshare               0.7.4                    py36_0    conda-forge
pip                       9.0.1                    py36_1    conda-forge
prompt_toolkit            1.0.15                   py36_0    conda-forge
ptyprocess                0.5.2                    py36_0    conda-forge
pycosat                   0.6.2            py36h1a0ea17_1    defaults
pycparser                 2.18             py36hf9f622e_1    defaults
pygments                  2.2.0                    py36_0    conda-forge
pyopenssl                 17.2.0           py36h5cc804b_0    defaults
pysocks                   1.6.7            py36hd97a5b1_1    defaults
python                    3.6.4                         0    conda-forge
python-dateutil           2.6.1                    py36_0    conda-forge
pyzmq                     16.0.2                   py36_3    conda-forge
readline                  7.0                           0    conda-forge
requests                  2.18.4           py36he2e5f8d_1    defaults
ruamel_yaml               0.11.14          py36ha2fb22d_2    defaults
setuptools                38.4.0                   py36_0    conda-forge
simplegeneric             0.8.1                    py36_0    conda-forge
six                       1.11.0                   py36_1    conda-forge
sqlite                    3.20.1                        2    conda-forge
terminado                 0.8.1                    py36_0    conda-forge
testpath                  0.3.1                    py36_0    conda-forge
tk                        8.6.7                         0    conda-forge
tornado                   4.5.3                    py36_0    conda-forge
traitlets                 4.3.2                    py36_0    conda-forge
urllib3                   1.22             py36hbe7ace6_0    defaults
wcwidth                   0.1.7                    py36_0    conda-forge
webencodings              0.5                      py36_0    conda-forge
wheel                     0.30.0                   py36_2    conda-forge
widgetsnbextension        2.0.1                    py36_0    conda-forge
xz                        5.2.3                         0    conda-forge
yaml                      0.1.7                h96e3832_1    defaults
zeromq                    4.2.1                         1    conda-forge
zlib                      1.2.11                        0    conda-forge
Neilabh21 commented 6 years ago

Running

jupyter nbextension enable --py widgetsnbextension

again worked for me. But using

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

did not work.

asimay commented 6 years ago

I used jupyterLab, it cannot work too. but I un-install the jupyterlab, and use jupyter, it can work.

meriburgess commented 6 years ago

I tried all of these things and nothing worked until I switched into a Python 3 kernel (previously trying to use a Python 2 kernel). Not sure if that is explicitly instructed anywhere, but thought it might be helpful to someone.

NatLun091238 commented 6 years ago

I use jupyterlab and I have the same issue. Nothing of above mentioned solutions help...

` ~ $ jupyter nbextension list Known nbextensions: config dir: /home/natallia/.jupyter/nbconfig notebook section jupyter-js-widgets/extension enabled

` Any ideas how to make it work for jupyter lab ???

michaelaye commented 6 years ago

Maybe this helps someone to get active figures back in jupyterlab:

  1. close all your notebooks and your jupyterlab server
  2. You need ipympl (= matplotlib/jupyter-matplotlib) (if you want active figures for zoom-in etc.)
  3. Be clean in your installed versions. The way I clean up when things are messed up: a. conda remove ipympl b. pip uninstall ipympl (in case I mixed GH/pip installs with conda) c. repeat b. until no ipympl is found, there can be more than one!
  4. conda install ipympl
  5. perform the required post-conda install steps as advised per their readme: a. conda install nodejs b. jupyter labextension install @jupyter-widgets/jupyterlab-manager
  6. When you launch jupyterlab and it asks to build stuff, do it! ;)

If you already have installed nodejs you can of course skip 4a. Also, there may be other steps you can skip, but this procedure helped me to get my matplotlib figures back, using %matplotlib ipympl

This worked for me on two different macOS 10.12.6 machines.

NatLun091238 commented 6 years ago

Fantastic, @michaelaye ! It was exactly, what was needed to make it work!!! Thank you a lot!

dragly commented 6 years ago

Thanks @michaelaye!

In my case, it appears ipywidgets was an old version even though the environment was recently set up.

In case anyone else is in the same situation as me: To install ipympl, I had to include -c conda-forge and added -c defaults before that for good measure:

conda install ipympl -c defaults -c conda-forge

This produced the following output:

The following NEW packages will be INSTALLED:

    ipympl:     0.1.1-py36_0 conda-forge

The following packages will be UPDATED:

    ipywidgets: 6.0.0-py36_0             --> 7.2.1-py36_0

So, apparently ipywidgets was outdated, and a new version was found in the defaults channel.

After running this, i removed both .config/jupyter and .local/share/jupyter to make sure no old config files were present. Finally, I ran the above-mentioned

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

and I now have interactive notebook widgets working in my new environment!