Jupyter笔记本:Widget未检测到Javascript

时间:2017-05-03 20:06:32

标签: jupyter-notebook

问题: 我在MacOs 10.9中使用pip3安装了python3和jupyter笔记本 当我尝试运行小部件时,它给出了没有javascript小部件的错误。 我在Jupyter-notebook中安装了python3和R内核。

代码:

from ipywidgets import widgets
from IPython.display import display
text = widgets.Text()
display(text)
text.on_submit('hello')

错误:

Widget Javascript not detected.  It may not be installed or enabled properly.  

尝试:

sudo -H pip3 install ipywidgets  
sudo -H pip3 install -upgrade ipywidgets  
jupyter nbextension enable --py widgetsnbextension
# restarted the computer. 

最后一个命令出错。

[EnableNBExtensionApp] CRITICAL | Bad config encountered during initialization:
[EnableNBExtensionApp] CRITICAL | Unrecognized flag: '--py'

请注意,在mac中我有jupyter-nbextension命令但命令:

jupyter-nbextension enable --py widgetsnbextension 

也不起作用。

但是jupyter nbextension enable widgetsnbextension没有错误,也没有做任何事情。如果我运行代码,则会弹出相同的错误。

此外,

import ipywidgets
ipywidgets.__version__

给出'6.0.0'。

一些注意事项:

which jupyter  
jupyter is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter
which jupyter-notebook
jupyter-notebook is /Library/Frameworks/Python.framework/Versions/3.5/bin/jupyter-notebook

相关链接:

https://github.com/jupyter-widgets/ipywidgets/issues/541    
https://github.com/jupyter/help/issues/32    
https://github.com/jupyter/help/issues/131    
https://github.com/binder-project/binder/issues/83   

如何安装小部件?
我需要单独安装java吗?

5 个答案:

答案 0 :(得分:4)

运行以下命令: jupyter nbextension enable --py --sys-prefix widgetsnbextension,然后在Jupyter中重新启动内核就可以了。

答案 1 :(得分:3)

我在Jupyter,Mac OS,Python 3.6和Anaconda中成功使用了以下命令。第一个命令此时获取最新版本的ipywidgets(版本7.0)。

server {
    listen 443;
    server_name www.somesite.ai;

    #The internal IP of the VM that hosts your Apache config

    location /{    
        if ($request_uri ~ ^/(\d+)/([^/]+)) {
            proxy_pass   http://192.168.X.XXX:$1/$2/;       
        }    

        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host:$server_port;
        proxy_buffering off;           
    }

    location ~ ^/(\d+)/static/ {
        try_files $uri  /bokehstatic/static/;      
    }
}

答案 2 :(得分:1)

这解决了我:

jupyter labextension install @jupyter-widgets/jupyterlab-manager

答案 3 :(得分:0)

我遇到了同样的问题,在运行命令jupyter nbextension enable --py --sys-prefix widgetsnbextension后,出现提示:

>Enabling notebook extension jupyter-js-widgets/extension...

- Validating: ok。 刷新你的jupyter笔记本,小部件工作。

答案 4 :(得分:-1)

可能是最好的方式,至少它对我有用:重新安装ipywidgets和widgetsextension它应该可以工作。

DECLARE @From DECIMAL (15,2) = 19.99;
DECLARE @To DECIMAL (15,2) = 20.02;
DECLARE @Step DECIMAL (15,2) = 00.01;
DECLARE @R TABLE (Value DECIMAL(15,2));

WHILE @From <= @To
    begin
        INSERT INTO @R VALUES (@From);
        SET @From = @From + @Step;
    End
SELECT *
FROM @R;