InsightSoftwareConsortium / itkwidgets

An elegant Python interface for visualization on the web platform to interactively generate insights into multidimensional images, point sets, and geometry.
https://itkwidgets.readthedocs.io/
Apache License 2.0
581 stars 83 forks source link

Error: Widgets require us to download supporting files from a 3rd party website. #396

Open pkuppens opened 3 years ago

pkuppens commented 3 years ago

Problem:

Error: Widgets require us to download supporting files from a 3rd party website. Click here to enable this or click here for more information. (Error loading itkwidgets:^0.32.0).

This occurs for me in Visual Studio Code + Windows Subsystem for Linux (WSL2) Ubuntu 20.04 LTS + Jupyter Notebook

The Jupyter notebook is as simple as:

import itk
from itkwidgets import view
from urllib.request import urlretrieve
import os

# Download data
file_name = '005_32months_T2_RegT1_Reg2Atlas_ManualBrainMask_Stripped.nrrd'
if not os.path.exists(file_name):
    url = 'https://data.kitware.com/api/v1/file/564a5b078d777f7522dbfaa6/download'
    urlretrieve(url, file_name)
image = itk.imread(file_name)
view(image, rotate=True, axes=True, vmin=4000, vmax=17000, gradient_opacity=0.9)

Reproduces:

Always

Consequence

The image does not display

What have I tried?

Of course, I tried to follow the 'here' links, but the magic didn't happen in link 1, and the information in link 2 is unfortunately inadequate for me: It says that it can be configured as follows "python.dataScience.widgetScriptSources": [ "jsdelivr.com", "unpkg.com"],

But where?? I tried the default settings file in the .vscode directory, but the setting is not recognized.

I also did some googling, and tried stuff line making sure I did not forget things like%matplotlib inline

Final remark

This could also be a Visual Studio Code issue?! But since I started having this issue when I started including itkwidgets, I submit the issue here.

thewtex commented 3 years ago

@pkuppens interesting, thanks for the report.

Does the same issue occur without Visual Studio Code, but with Windows Subsystem for Linux (WSL2) Ubuntu 20.04 LTS + Jupyter Notebook?

pkuppens commented 3 years ago

@thewtex , I tried to check as much as I can to support your great work, by making it as efficient as possible.

I installed Jupyter (Jupyter Lab to be precise) on my WSL2 installation.

I do not get the warning/error, but I do not get the viewer either, I only get a message that looks like constructor debugging: Viewer(axes=True, geometries=[], gradient_opacity=0.9, point_sets=[], rendered_image=<itk.itkImagePython.itkIm…

For further debugging, I recall I probably did not set the "widgetScriptSources": [ "jsdelivr.com", "unpkg.com"], (how?)

When I tried to configure these widgetScriptSources, I found that I might need to do (for jupyterlab) jupyter labextension install @jupyter-widgets/jupyterlab-manager jupyter-matplotlib jupyterlab-datawidgets itkwidgets

However, that failed repeatedly. The first few errors I could find, they were due to expectation on the existence of nodejs, npm, webpack.

After sudo apt installing those, it finally fails on error /home/pieter/miniconda3/share/jupyter/lab/staging/node_modules/jupyter-matplotlib: Command failed. Exit code: 1

When investigating, I found that that was a directory, not an executable, but I do not know where to continue debugging/investigating.

pkuppens commented 3 years ago

By the way, this issue is also submitted here:

https://github.com/microsoft/vscode-jupyter/issues/4246

Observation there is that there are a few more widgets with issues.

thewtex commented 3 years ago

@pkuppens thank you for the further investigations!

So cool that we can have the interactive, 3D visualizations inside Visual Studio Code!

Another moving target to be aware of -- JupyterLab 3 was just released. This addresses a long standing issue with JupyterLab: extensions required a re-build of the JavaScript bundles and made it was difficult to host associated files -- we were hosting on CDN's to work around this. The good news is that this pain will be removed as we update to JupyterLab 3 (#397 ). The bad news is that JupyterLab 3 will not work until then (check your installation for your Jupyter version, and use 2 for now).