Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't add children widget to box when rendering widgets #233

Closed
aggFTW opened this issue Nov 7, 2015 · 9 comments
Closed

Couldn't add children widget to box when rendering widgets #233

aggFTW opened this issue Nov 7, 2015 · 9 comments
Labels
discussion needs info resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@aggFTW
Copy link

aggFTW commented Nov 7, 2015

Hi,

I don't know if there is a bug in ipywidgets or if there's an opportunity to refactor IPythonKernel. I'd appreciate your comments.

I recently created a kernel that inherits directly from IPythonKernel: class MyKernel(IPythonKernel)
This MyKernel class is a very thin layer over the IPythonKernel.

On this kernel, if the user tries to display a Widget in MyKernel, they'll get a Javascript error that I am having a very hard time debugging. Message from browser console below. Notice that the widget tabs omit the content of the widget children:
screen shot 2015-11-03 at 6 43 00 pm

When i run the same piece of code that renders the same widget on the real IPythonKernel, it looks like this, with children displaying correctly:
screen shot 2015-11-03 at 6 45 17 pm

Any help would be appreciated!

Thanks!

Javascript error message:

Uncaught (in promise) WrappedError {stack: "Error: Couldn't add child view to box↵    at new E…in.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33", message: "Couldn't add child view to box", error_stack: Array[4]}error_stack: Array[4]0: TypeError: require is not a function
    at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12740:17
    at Object.load_class (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12736:16)
    at http://localhost:8888/nbextensions/widgets/widgets/js/manager.js?v=20151103005149:74:261: Error: Couldn't create a view for model id '5ce5e524d89f44fd84f229604853b122'
    at new Error (native)
    at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
    at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message: "Couldn't create a view for model id '5ce5e524d89f44fd84f229604853b122'"stack: (...)get stack: ()set stack: ()__proto__: DefineError.bh2: Error: Couldn't create child view
    at new Error (native)
    at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
    at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message: "Couldn't create child view"stack: (...)get stack: ()set stack: ()__proto__: DefineError.bh3: Error: Couldn't add child view to box
    at new Error (native)
    at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
    at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33length: 4__proto__: Array[0]message: "Couldn't add child view to box"stack: "Error: Couldn't add child view to box↵    at new Error (native)↵    at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)↵    at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33"__proto__: Object

ping @ellisonbg

@ellisonbg
Copy link
Member

Hmm, not exactly sure what is going on there. Can I look at the custom
kernel code somewhere? I am not sure how wrapper kernels will work with
widgets, but I can look at it.

On Fri, Nov 6, 2015 at 8:20 PM, Alejandro Guerrero Gonzalez <
notifications@github.com> wrote:

Hi,

I don't know if there is a bug in ipywidgets or if there's an opportunity
to refactor IPythonKernel. I'd appreciate your comments.

I recently created a kernel that inherits directly from IPythonKernel: class
MyKernel(IPythonKernel)
This MyKernel class is a very thin layer over the IPythonKernel.

On this kernel, if the user tries to display a Widget in MyKernel,
they'll get a Javascript error that I am having a very hard time debugging.
Message from browser console below. Notice that the widget tabs omit the
content of the widget children:
[image: screen shot 2015-11-03 at 6 43 00 pm]
https://cloud.githubusercontent.com/assets/654204/10928159/f89beefe-825a-11e5-8f13-3135cb67aa80.png

When i run the same piece of code that renders the same widget on the real
IPythonKernel, it looks like this, with children displaying correctly:
[image: screen shot 2015-11-03 at 6 45 17 pm]
https://cloud.githubusercontent.com/assets/654204/10928181/24373c30-825b-11e5-92fb-3010ec906b0e.png

Any help would be appreciated!

Thanks!

Javascript error message:

Uncaught (in promise) WrappedError {stack: "Error: Couldn't add child view to box↵ at new E…in.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33", message: "Couldn't add child view to box", error_stack: Array[4]}error_stack: Array[4]0: TypeError: require is not a function
at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12740:17
at Object.load_class (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12736:16)
at http://localhost:8888/nbextensions/widgets/widgets/js/manager.js?v=20151103005149:74:261: Error: Couldn't create a view for model id '5ce5e524d89f44fd84f229604853b122'
at new Error (native)
at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message: "Couldn't create a view for model id '5ce5e524d89f44fd84f229604853b122'"stack: (...)get stack: ()set stack: ()proto: DefineError.bh2: Error: Couldn't create child view
at new Error (native)
at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message: "Couldn't create child view"stack: (...)get stack: ()set stack: ()proto: DefineError.bh3: Error: Couldn't add child view to box
at new Error (native)
at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)
at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33length: 4__proto__: Array[0]message: "Couldn't add child view to box"stack: "Error: Couldn't add child view to box↵ at new Error (native)↵ at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)↵ at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33"**proto**: Object

ping @ellisonbg https://github.com/ellisonbg


Reply to this email directly or view it on GitHub
#233.

Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@aggFTW
Copy link
Author

aggFTW commented Nov 7, 2015

@ellisonbg
Copy link
Member

I don't think this is your custom kernel code. Some things to check:

  • Are you using two versions of python, one with the main ipython kernel,
    another with the custom kernel?
  • Is ipywidgets installed propertly (with the JS) in both?
  • Clear your browser cache and reload the page.
  • Install ipywidgets from master

On Fri, Nov 6, 2015 at 10:48 PM, Alejandro Guerrero Gonzalez <
notifications@github.com> wrote:

Sure thing. It's here:
https://github.com/jupyter-incubator/sparkmagic/blob/master/remotespark/pysparkkernel/pysparkkernel.py
Thanks Brian!

On Fri, Nov 6, 2015 at 7:43 PM -0800, "Brian E. Granger" <
notifications@github.com> wrote:

Hmm, not exactly sure what is going on there. Can I look at the custom

kernel code somewhere? I am not sure how wrapper kernels will work with

widgets, but I can look at it.

On Fri, Nov 6, 2015 at 8:20 PM, Alejandro Guerrero Gonzalez <

notifications@github.com> wrote:

Hi,

I don't know if there is a bug in ipywidgets or if there's an opportunity

to refactor IPythonKernel. I'd appreciate your comments.

I recently created a kernel that inherits directly from IPythonKernel:
class

MyKernel(IPythonKernel)

This MyKernel class is a very thin layer over the IPythonKernel.

On this kernel, if the user tries to display a Widget in MyKernel,

they'll get a Javascript error that I am having a very hard time
debugging.

Message from browser console below. Notice that the widget tabs omit the

content of the widget children:

[image: screen shot 2015-11-03 at 6 43 00 pm]

<
https://cloud.githubusercontent.com/assets/654204/10928159/f89beefe-825a-11e5-8f13-3135cb67aa80.png

When i run the same piece of code that renders the same widget on the
real

IPythonKernel, it looks like this, with children displaying correctly:

[image: screen shot 2015-11-03 at 6 45 17 pm]

<
https://cloud.githubusercontent.com/assets/654204/10928181/24373c30-825b-11e5-92fb-3010ec906b0e.png

Any help would be appreciated!

Thanks!

Javascript error message:

Uncaught (in promise) WrappedError {stack: "Error: Couldn't add child
view to box↵ at new E…in.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33",
message: "Couldn't add child view to box", error_stack:
Array[4]}error_stack: Array[4]0: TypeError: require is not a function

at
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12740:17

at Object.load_class (
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12736:16
)

at
http://localhost:8888/nbextensions/widgets/widgets/js/manager.js?v=20151103005149:74:261:
Error: Couldn't create a view for model id
'5ce5e524d89f44fd84f229604853b122'

at new Error (native)

at Error.WrappedError (
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25
)

at
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message:
"Couldn't create a view for model id
'5ce5e524d89f44fd84f229604853b122'"stack: (...)get stack: ()set stack:
()proto: DefineError.bh2: Error: Couldn't create child view

at new Error (native)

at Error.WrappedError (
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25
)

at
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33message:
"Couldn't create child view"stack: (...)get stack: ()set stack:
()proto: DefineError.bh3: Error: Couldn't add child view to box

at new Error (native)

at Error.WrappedError (
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25
)

at
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33length:
4__proto__: Array[0]message: "Couldn't add child view to box"stack: "Error:
Couldn't add child view to box↵ at new Error (native)↵ at
Error.WrappedError (
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25)↵
at
http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12785:33"**proto**:
Object

ping @ellisonbg https://github.com/ellisonbg

Reply to this email directly or view it on GitHub

#233.

Brian E. Granger

Associate Professor of Physics and Data Science

Cal Poly State University, San Luis Obispo

@ellisonbg on Twitter and GitHub

bgranger@calpoly.edu and ellisonbg@gmail.com


Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#233 (comment).

Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@jdfreder jdfreder added this to the 5.0 milestone Nov 7, 2015
@jdfreder
Copy link
Contributor

jdfreder commented Nov 9, 2015

Strange, I thought I had responded to this. I just wanted to echo @ellisonbg 's suggestion that you should double check if you are running two versions of Python or not, and if so, that the versions of ipywidgets match on both. The symptoms you post point to that.

Background: ipywidgets is not only a package used by you in Python, but it's also a package used by the webserver to host static content. It's crtitical that both run the same version of ipywidgets because the static content hosted by the webserver is designed to communicate with the code you run in the kernel.

@aggFTW
Copy link
Author

aggFTW commented Nov 9, 2015

Thanks for your answers @ellisonbg and @jdfreder.
Let me try your suggestions and report back :)

@aggFTW
Copy link
Author

aggFTW commented Nov 19, 2015

So I've been looking at this all night and cannot figure out what's going on...

Both kernels are using the same Python version, running on the same kernel.
Furthermore, I also just experienced this in the ipython kernel itself. It's weird because I have another notebook where it works.

I installed ipywidgets from master and cleared the browser. Now, I get this error message on first execution:

0: Error: Class ipython.widget not found in registry at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12751:28 at O (eval at <anonymous> (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), <anonymous>:8:15049) at new V (eval at <anonymous> (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), <anonymous>:8:16254) at Object.load_class (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12736:16) at CommManager.comm_open (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:21802:37) at x.isFunction.i (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:5488) at Kernel._handle_iopub_message (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:23101:20) at Kernel._finish_ws_message (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:22936:29) at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:22926:44 at P (eval at <anonymous> (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), <anonymous>:8:14792)
1: Error: Could not open comm at new Error (native) at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25) at...

As far as I know I only have Anaconda's Python 2.7 (Python 2.7.10 |Anaconda 2.3.0 (x86_64)) and one version of ipywidgets installed ('4.2.0.dev').

I did some searches and found this: ipython/ipython#6493
Maybe @SylvainCorlay would know? 😃

@ellisonbg How can I verify if ipywidgets is installed propertly (with the JS) in both? I didn't quite get that question.

Thanks in advance!

@ellisonbg
Copy link
Member

A few questions:

  • What version of the notebook do you have installed?
  • How did you do the install?
  • Can you run pip/conda list to see what versions of ipywidgets you have
    installed - you may have multiple versions.

On Thu, Nov 19, 2015 at 2:33 AM, Alejandro Guerrero Gonzalez <
notifications@github.com> wrote:

So I've been looking at this all night and cannot figure out what's going
on...

Both kernels are using the same Python version, running on the same kernel.
Furthermore, I also just experienced this in the ipython kernel itself.
It's weird because I have another notebook where it works.

I installed ipywidgets from master and cleared the browser. Now, I get
this error message on first execution:

0: Error: Class ipython.widget not found in registry at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12751:28 at O (eval at (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), :8:15049) at new V (eval at (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), :8:16254) at Object.load_class (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12736:16) at CommManager.comm_open (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:21802:37) at x.isFunction.i (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:5488) at Kernel._handle_iopub_message (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:23101:20) at Kernel._finish_ws_me
ssage (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:22936:29) at http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:22926:44 at P (eval at (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:89:4231), :8:14792)
1: Error: Could not open comm at new Error (native) at Error.WrappedError (http://localhost:8888/static/notebook/js/main.min.js?v=40e10638fcf65fc1c057bff31d165e9d:12706:25) at...

As far as I know I only have Anaconda's Python 2.7 (Python 2.7.10
|Anaconda 2.3.0 (x86_64)) and one version of ipywidgets installed
('4.2.0.dev').

I did some searches and found this: ipython/ipython#6493
ipython/ipython#6493
Maybe @SylvainCorlay https://github.com/SylvainCorlay would know? [image:
😃]

@ellisonbg https://github.com/ellisonbg How can I verify if ipywidgets
is installed propertly (with the JS) in both? I didn't quite get that
question.

Thanks in advance!


Reply to this email directly or view it on GitHub
#233 (comment).

Brian E. Granger
Associate Professor of Physics and Data Science
Cal Poly State University, San Luis Obispo
@ellisonbg on Twitter and GitHub
bgranger@calpoly.edu and ellisonbg@gmail.com

@aggFTW
Copy link
Author

aggFTW commented Mar 8, 2016

Visitors from the future:

My issue was I had installed ipywidgets via pip with a conda installation and there was indeed a version mismatch between the conda and pip ipywidget installation.

When I resolved the inconsistency, issue went away.

Thanks for the help everyone!

@aggFTW aggFTW closed this as completed Mar 8, 2016
@Cnstant
Copy link

Cnstant commented Mar 23, 2016

Hi,

I have an equivalent problem. Whenever I try to use an ipywidgets object in a notebook, I get the error 'Could not open comm -- Error: Class ipython.widget not found in registry' in the web console. It seems to be related

I checked every point you mentioned, especially the inconsistency between pip and conda, but I still can't figure out what is wrong.

Ex : from ipywidgets import IntSlider
IntSlider()

returns nothing, and prints out the aforementioned error

@github-actions github-actions bot added the resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Feb 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
discussion needs info resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

4 participants