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
579 stars 83 forks source link

The Python module itkwidgets is not a valid nbextension #639

Closed vonodiripsa closed 5 months ago

vonodiripsa commented 1 year ago

itkwidgets viewer is not working in Azure ML Notebook (jupyter) I did try a solution from https://github.com/InsightSoftwareConsortium/itkwidgets/issues/425#top

jupyter nbextension install --py itkwidgets jupyter nbextension enable --py itkwidgets

But itkwidgets is not a valid nbextension...

On Azure ML with itkwidgets 1.0a25:

(azureml_py310_sdkv2) azureuser@nc64ast4v3:~$ jupyter nbextension install --py itkwidgets Traceback (most recent call last): File "/anaconda/envs/azureml_py310_sdkv2/bin/jupyter-nbextension", line 8, in sys.exit(main()) File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/jupyter_core/application.py", line 277, in launch_instance return super().launch_instance(argv=argv, **kwargs) File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/traitlets/config/application.py", line 985, in launch_instance app.start() File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/notebook/nbextensions.py", line 972, in start super().start() File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/jupyter_core/application.py", line 266, in start self.subapp.start() File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/notebook/nbextensions.py", line 702, in start self.install_extensions() File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/notebook/nbextensions.py", line 675, in install_extensions full_dests = install(self.extra_args[0], File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/notebook/nbextensions.py", line 203, in install_nbextension_python m, nbexts = _get_nbextension_metadata(module) File "/anaconda/envs/azureml_py310_sdkv2/lib/python3.10/site-packages/notebook/nbextensions.py", line 1109, in _get_nbextension_metadata raise KeyError( KeyError: 'The Python module itkwidgets is not a valid nbextension, it is missing the _jupyter_nbextension_paths() method.' (azureml_py310_sdkv2) azureuser@nc64ast4v3:~$ conda install -c conda-forge jupyter_contrib_nbextensions Collecting package metadata (current_repodata.json): done Solving environment: done

bnmajor commented 1 year ago

Hi @vonodiripsa! The latest version of itkwidgets is actually the pre-release, v1.0a25 which I recommend that you use. It is not an nbextension but it is a python package so you can simply pip install it! In a cell:

!pip install "itkwidgets[all]>=1.0a25"

You can also check out the notebooks in our examples if you'd like to see some different use cases demoed. :slightly_smiling_face:

vonodiripsa commented 1 year ago

Sorry, what I am trying to say. The version 1.0a25 (the same like old versions) is not working on Azure ML. If, for example, you load your MONAI sample notebook example it will not show anything in the your viewer. It will show only a text message: <itkwidgets.viewer.Viewer at 0x7f5a3f7bebf0>

bnmajor commented 1 year ago

@vonodiripsa Got ya! I'm not familiar with Azure ML myself, but my first thought is that imjoy-jupyterlab-extension may be installed but not loaded. We have an environment check notebook that is designed to be run before the example notebooks to make sure your environment is set up correctly that you may want to try. I can also reach out to some others to see if anyone else has some Azure ML experience and may see pieces that I am missing.

vonodiripsa commented 1 year ago

I did run the environment check. It fails at:

if os.environ.get('CONDA_DEFAULT_ENV', None): !conda install --yes -q --prefix {sys.prefix} -c conda-forge pyimagej else: raise RuntimeError("No conda environment is activated, currently unable to install pyimagej. Please activate a conda environment and re-run this cell.")

This is the error: RuntimeError Traceback (most recent call last) Input In [5], in <cell line: 1>() 2 get_ipython().system('conda install --yes -q --prefix {sys.prefix} -c conda-forge pyimagej') 3 else: ----> 4 raise RuntimeError("No conda environment is activated, currently unable to install pyimagej. Please activate a conda environment and re-run this cell.")

RuntimeError: No conda environment is activated, currently unable to install pyimagej. Please activate a conda environment and re-run this cell.

I am actually running using one of conda environments on Azure ML compute (VM).

 active environment : azureml_py310_sdkv2
active env location : /anaconda/envs/azureml_py310_sdkv2
        shell level : 6
   user config file : /home/azureuser/.condarc

populated config files : conda version : 22.11.1 conda-build version : not installed python version : 3.10.8.final.0 virtual packages : __archspec=1=x86_64 cuda=11.4=0 glibc=2.31=0 linux=5.15.0=0 unix=0=0 base environment : /anaconda (writable) conda av data dir : /anaconda/etc/conda conda av metadata url : None channel URLs : https://repo.anaconda.com/pkgs/main/linux-64 https://repo.anaconda.com/pkgs/main/noarch https://repo.anaconda.com/pkgs/r/linux-64 https://repo.anaconda.com/pkgs/r/noarch package cache : /anaconda/pkgs /home/azureuser/.conda/pkgs envs directories : /anaconda/envs /home/azureuser/.conda/envs platform : linux-64 user-agent : conda/22.11.1 requests/2.28.1 CPython/3.10.8 Linux/5.15.0-1031-azure ubuntu/20.04.5 glibc/2.31 UID:GID : 1000:1000 netrc file : None offline mode : False

Thanks, Alexander

From: Brianna Major @.> Sent: Monday, March 27, 2023 12:33 PM To: InsightSoftwareConsortium/itkwidgets @.> Cc: Alexander Spiridonov @.>; Mention @.> Subject: Re: [InsightSoftwareConsortium/itkwidgets] The Python module itkwidgets is not a valid nbextension (Issue #639)

@vonodiripsahttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fvonodiripsa&data=05%7C01%7Caspiridonov%40nvidia.com%7C2e184838635b4bab7bf608db2efa0b20%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638155423689385435%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CMe0sf1Mkcfl%2FG15fH%2FxLHngGBM1E3dvO%2B%2BG9dmM5ck%3D&reserved=0 Got ya! I'm not familiar with Azure ML myself, but my first thought is that imjoy-jupyterlab-extension may be installed but not loaded. We have an environment checkhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FInsightSoftwareConsortium%2Fitkwidgets%2Fblob%2Fmain%2Fexamples%2FEnvironmentCheck.ipynb&data=05%7C01%7Caspiridonov%40nvidia.com%7C2e184838635b4bab7bf608db2efa0b20%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638155423689385435%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=gD0%2B07dyvueY12ualLHAi8RdJcYUjEtFakwfhQ%2FVI88%3D&reserved=0 notebook that is designed to be run before the example notebooks to make sure your environment is set up correctly that you may want to try. I can also reach out to some others to see if anyone else has some Azure ML experience and may see pieces that I am missing.

- Reply to this email directly, view it on GitHubhttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FInsightSoftwareConsortium%2Fitkwidgets%2Fissues%2F639%23issuecomment-1485750625&data=05%7C01%7Caspiridonov%40nvidia.com%7C2e184838635b4bab7bf608db2efa0b20%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638155423689385435%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=yWPYoowa7KrRUHcURxZMU8dMd3Yn2w2Y7he6GWpsu9s%3D&reserved=0, or unsubscribehttps://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAB3NPRCB7M5G3ARKTPZ45H3W6HTN5ANCNFSM6AAAAAAWFSFXUQ&data=05%7C01%7Caspiridonov%40nvidia.com%7C2e184838635b4bab7bf608db2efa0b20%7C43083d15727340c1b7db39efd9ccc17a%7C0%7C0%7C638155423689541665%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=W9kpqUn4LkMKJk6T5kLlRZk%2BQw2qthyaWzgKTSmqH%2BE%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.**@.>>

bnmajor commented 1 year ago

Thanks for the info! I will need to look into the issue detecting conda environments with Azure. For now it sounds like you don't need PyImageJ though so could you try commenting out that cell so that the remaining cells are run?

vonodiripsa commented 1 year ago

All other steps don't have any messages

bnmajor commented 1 year ago

@vonodiripsa The imjoy-jupyterlab-extension is required for the itkwidgets output to be displayed and unfortunately I am almost positive that whatever is going wrong with the output here is related to however Azure ML is handling jupyterlab extensions. We would need to meet with someone who has knowledge of how Azure ML is designed in order to sort out what may be going wrong here. If you know anyone at Microsoft developing or working on this that would be able to reach out to myself or @thewtex we would be happy to work with them!

vonodiripsa commented 1 year ago

Thanks. I am trying to find the right contact person.

jxfruit commented 5 months ago

any update? the same issue with jupyter-notebook and latest itkwidgets in docker environment

thewtex commented 5 months ago

Should be addressed with #741

thewtex commented 5 months ago

Should be addressed with itkwidgets v1.0a50. If not, please re-open. Thanks!

jxfruit commented 5 months ago

new issue: AttributeError: 'NoneType' object has no attribute 'kernel' notebook 6.4.3 and itkwidgets 1.0a50

thewtex commented 3 months ago

@jxfruit please update to notebook 7. Please open a new issue for follow-ups. Thanks

jxfruit commented 3 months ago

@jxfruit please update to notebook 7. Please open a new issue for follow-ups. Thanks @thewtex sorry, we cannot upgrade notebook 7, because we are using notebook 6. From version 6.x to 7.x, there are many changes, which is unacceptable. Can your update with notebook 6, thanks!