Comments (5)
The Slicer Jupyter kernel worked for me in VS code a few months ago, but not anymore. When I executed a cell in the notebook I got an error message that the connection_file
was not found in the argument list in kernel.json, which was clearly wrong. After adding a dummy connection_file
argument, it complained that it expects the kernel arguments to be exactly a certain format (something like python-executable -m modulename arg1 arg2...
), which is nonsense (the server should not dictate a specific format for how to call the kernel executable). I've also tried "Existing" Jupyter server options in VS Code GUI and when I copied the server address there and hit Enter, nothing happened. There may be things around the Slicer kernel that work slightly differently than a regular Python kernel, but it looks like notebook support in VS code is broken or at least really fragile.
I've added this line to the slicer startup file (C:\Users\andra\.slicerrc.py
) to print what VS code does:
print("arguments="+repr(slicer.app.arguments()))
And I got this in the application log:
[INFO][Stream] 08.02.2021 18:50:22 [] (unknown:0) - arguments=(
'C:\\Users\\andra\\AppData\\Local\\NA-MIC\\Slicer 4.13.0-2021-02-04\\bin\\SlicerApp-real.exe',
'c:\\Users\\andra\\.vscode\\extensions\\ms-python.python-2021.1.502429796\\pythonFiles\\pyvsc-run-isolated.py',
'c:\\Users\\andra\\.vscode\\extensions\\ms-python.python-2021.1.502429796\\pythonFiles\\interpreterInfo.py')
So, it seems that VS code wants to retrieve information about the interpreter with some custom script, which is totally arbitrary. VS code imposes restrictions and makes assumptions that may be OK for a plain Python kernel using Python or conda distribution but totally inappropriate for custom kernel implementations.
You can try to go back to an earlier Python/Jupyter extension version in VS code or wait for a newer version that has better interoperability.
from slicerjupyter.
Thanks for looking into this I appreciate it! I will rollback to an earlier Jupyter extension or simply use the web based jupyter if that doesn't work.
from slicerjupyter.
OK! Let us know if rollback works.
from slicerjupyter.
VS Code still cannot start the server in Slicer's virtual Python environment but if the server is started from Slicer then VS Code can connect to the running server:
- Start Slicer, go to JupyterKernel module, click Start Jupyter server
- Get the Jupyter server URL from the Slicer application log (it should be something like
http://localhost:8888/lab?token=afc2a22bbe61149ae7c2e831645e5b28384203eb3c3c2da5
), copy to the clipboard - In Visual Studio code, open a notebook, click in the lower-right corner on "Jupyter server: ..." then select at the list at the top center "Pick how to connect to jupyter" -> "Existing", paste the server URL from the clipboard and hit Enter
- If in the top-right corner the kernel is not "Slicer 4.13" then click there and choose "Slicer 4.13" from the list that appears in the top center
from slicerjupyter.
I've made some fixes to improve compatibility when using SlicerJupyter as a local server. How to make local server work:
- select PythonSlicer as Python interpreter
- choose Slicer-4.13 as kernel
It seems that the kernel does not show up if the language in kernel.json is set to "python" and changing it to anything else (for example "pythonX") makes it appear.
It may also be necessary to install the kernelspec in the PythonSlicer requirement, replacing --user
by --sys-prefix
.
Overall, VSCode Jupyter extension seems to struggle with all but the most basic Jupyter configurations. There are dozens of open issues and support for custom kernels, such as XEUS (that Slicer uses) is quite low on the priority list.
from slicerjupyter.
Related Issues (20)
- Kernel doesn't start HOT 1
- Missing SlicerJupyter HOT 4
- Missing version on configure file path HOT 2
- Linux: extension SlicerJupyter not available in 4.13 preview releases HOT 18
- Shutdown all Slicer Jupyter kernels??? HOT 3
- Help me! Update plane from fiducial points...How can I aligne the red plane with Coordinate axis? HOT 1
- Kernel misses autoreload IPython extension HOT 5
- SlicerJupyter not found in 3DSlicer Extension Manager HOT 2
- Extension failed to download - Using Slicer UI HOT 3
- SlicerKernel and getpass.getpass() echoing to the notebook. HOT 2
- Unable to package SlicerJupyter
- Rename `python-packages` external project to `python-slicerjupyter-requirements`
- Add JupyterLab debugger support
- Slicer Kernel cannot start HOT 5
- Integration of Slicer notebook in Jupyter Hub HOT 2
- Integration of jupyter slicer notebook in jupyterhub HOT 1
- Unable to remove SlicerJupyter HOT 4
- Update dependency to use updated Xeus (3.0) modules
- [MacOS] Slicer does not start after installing SlicerJupyter HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from slicerjupyter.