I have a few questions for getting a working setup of the jupyter notebook extension and Slicer working within VSCode. I’m still fairly new to making the switch from MATLAB to python, so some of these may be fairly obvious questions I am missing.
My main questions are:
How to make sure I am pointing to the correct kernel to run a .ipynb file within vscode
How to enable a debugger for jupyter lab in either vscode or within jupyter lab when running a slicer kernel
For the first question:
Currently on my Mac I recently installed Slicer 5.0.3 which I think overwrote Slicer 4.11. When running a jupyter notebook in jupyter lab with a slicer 5.0 kernel, the notebook works as expected. However, my Mac (and our lab’s PC I’ve set this up on) seems to think there are two available slicer kernels
When trying to run a jupyternotebook in vscode, it seems to only recognize the 4.11 kernel, and when I check the directory it is pointing the executable file it points to I believe should now be 5.0
A minor question: when I launch vscode with the 4.11 kernel, it wants to launch 4 instances of slicer that shutdown quickly, and reduce to one running instance, but I’m wondering if there’s a way to get stop this behavior
I really appreciate the help! Please, let me know how to proceed or if there are posts I might have missed that address this.
Last time I tried VSCode had poor support for xeus kernels (slicer’s kernel is one of those). The workaround would be to use the VSCode remote jupyter kernel extension and launch the slicer-jupyter docker container. Then you should be able to connect to the kernel in the container from vscode
Thank you this is very helpful to know! I will likely just stick with jupyterlab then instead of VS code since it seems to be a good working setup. At least until there is better support for xeus.
Do you have any suggestions for getting a debugger working in jupyter lab with a xeus kernel?
I also tried following some of the advice on this thread (https://discourse.slicer.org/t/developing-slicer-modules-in-visual-studio-visual-studio-code/9496/20) for setting up the correct python paths and autocomplete paths for vscode, but haven’t quite been able get autocompletion to work or recognize “import slicer” for example. From my understanding of this thread, it seems that getting a debugging connection alone will allow autocompletion?
To start debugging, you need to click “Connect” in Slicer before you can attach in VS Code. Follow exactly these steps.
What may be confusing is that the VS Code screenshot shows all 4 clicks that you need to make in VS Code. For initial setup you only need to click 1 and 2. Click 3 and 4 are for for starting debugging and they should be clicked after “Connect” button was clicked in Slicer.