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

ModuleNotFoundError: No module named 'IPython': when running notebook in debug mode via VScode #145

Open
jcohenadad opened this issue Nov 1, 2024 · 5 comments

Comments

@jcohenadad
Copy link
Contributor

getting this when running notebook in debug mode via VScode:

sct_qc -i sub-MGH2_UNIT1.nii.gz -s sub-MGH2_UNIT1_seg_labeled.nii.gz -p sct_label_vertebrae -qc /Users/julien/code/coil-qc-code/data-human/qc -qc-subject sub-MGH2
--


*** Generating Quality Control (QC) html report ***
Traceback (most recent call last):
  File "/Users/julien/code/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_qc.py", line 125, in <module>
    main(sys.argv[1:])
  File "/Users/julien/code/spinalcordtoolbox/spinalcordtoolbox/scripts/sct_qc.py", line 108, in main
    generate_qc(fname_in1=arguments.i,
  File "/Users/julien/code/spinalcordtoolbox/spinalcordtoolbox/reports/qc.py", line 632, in generate_qc
    qc_image._make_QC_image_for_3d_volumes(img, mask, plane, imgs_to_generate)
  File "/Users/julien/code/spinalcordtoolbox/spinalcordtoolbox/reports/qc.py", line 228, in _make_QC_image_for_3d_volumes
    fig = mpl_plt.figure()
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/pyplot.py", line 1027, in figure
    manager = new_figure_manager(
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/pyplot.py", line 549, in new_figure_manager
    _warn_if_gui_out_of_main_thread()
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/pyplot.py", line 526, in _warn_if_gui_out_of_main_thread
    canvas_class = cast(type[FigureCanvasBase], _get_backend_mod().FigureCanvas)
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/pyplot.py", line 358, in _get_backend_mod
    switch_backend(rcParams._get("backend"))
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/pyplot.py", line 415, in switch_backend
    module = backend_registry.load_backend_module(newbackend)
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib/backends/registry.py", line 323, in load_backend_module
    return importlib.import_module(module_name)
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib_inline/__init__.py", line 1, in <module>
    from . import backend_inline, config  # noqa
  File "/Users/julien/code/spinalcordtoolbox/python/envs/venv_sct/lib/python3.9/site-packages/matplotlib_inline/backend_inline.py", line 13, in <module>
    from IPython.core.interactiveshell import InteractiveShell
ModuleNotFoundError: No module named 'IPython'

Probably related to #134

@jcohenadad
Copy link
Contributor Author

One thing, is that IPython is not in the requirements.txt, but it is install in my local env. But in any case, we should add it to the requirements.txt so GHA can properly run the notebook

jcohenadad added a commit that referenced this issue Nov 1, 2024
@jcohenadad
Copy link
Contributor Author

Installing IPython and updating my local venv solved it. Will push the fix shortly.

@jcohenadad
Copy link
Contributor Author

pushed: af8ad9a

@jcohenadad
Copy link
Contributor Author

FWIT: The issue reappeared, even though I've been using the same VScode and environment. I think there might be a feature in jupyter and/or VScode that times how long a notebook runs, and after a while IPython becomes somehow unloaded (???).

@jcohenadad
Copy link
Contributor Author

Reopening this issue, and also opened an issue on SCT.

In the meantime, i will comment out all the calls to sct_qc in the notebook, to avoid excessive errors. Will need to un-comment once the issue is fixed.

@jcohenadad jcohenadad reopened this Nov 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant