Sc_kernel - SuperCollider / sclang kernel for Jupyter

Jupyter is an environment which allows to use a repl in a browser. This allows for rich text source code which can embedd videos, images, LaTeX code as well as audio. Jupyter is heavily used in Data Science and Machine Learning and is also known via the proprietary fork Google Colab.
I heard sagas that old SuperCollider versions supported rich text as source code - now it is back :slight_smile:

I started coding this in 2020 and used it since to create some course materials for websites but decided to give this a proper release by anouncing it here. Have in mind that this is still a beta (currently @ v0.4.0), any contributions are welcome.

Stepping into the Jupyter ecosystem allows to use e.g. Jupyter Book or use its real time collaboration features (see below).

Installation

Assuming you have python with pip installed as well as SuperCollider (of course) it is as easy as

pip3 install --upgrade sc_kernel

You may want to take a look at venv to keep your python environment clean.

Right now I am unsure if this will work under Windows - I don’t have a machine to test the delicate piping of the sclang process, any help via a PR is welcome here :slight_smile:

I only tested this with macOS (intel) and Ubuntu 22.04

Quickstart

To start a Jupyter lab server simply call

jupyter lab

and create a new SuperCollider notebook.

If everything worked out one can execute sclang commands in the browser now.
As Jupyter is already cell oriented there is no need to create surrounding ( ) brackets anymore!
To execute a cell simply hit <shift> + <return>.
Anything that is printed in sync by the command will be displayed below the cell, making it clear what each command returned.

So what is not printing printing in-sync? Tdef, Routine or s.boot are running async - if these fails you are a bit out of luck currently in sc_kernel as you won’t be seeing any error messages of them (I still don’t know how to handle async printing in a good way, any recommendations are welcome!)

Before we continue: The infamous <cmd> + . command is not available here! To stop any sound simply enter a .

image

Features

I added some “magic functions” one is used to from the Python notebooks. These are simply functions which are prepended to each script cell call.
Check out the documentation for more extensive info about these features

Real time collaboration

Allows to share/sync/execute code over the network - each participant can join via a browser and can execute commands. The cursor of each participant is displayed as well.
This can allow for some cool shared live coding experiments!

sharing

Recording audio

Embedd a short snippet of your server audio directly into the notebook

Embedding plots

Autocomplete

Still WIP - completes class names (if they are longer than 3 chars) when hitting <tab> asking the interpreter for matching classes.

I want to embedd method auto-completion here as well, probably for v0.5.0.

Documentation

Display the raw schelp file of a class by prepending a ? to the class

Also works by hitting <shift> + <tab> when the cursor is behind an existing class.

For v0.5.0 I maybe want to mimic displaying the help file via an inspector.

7 Likes

Because of limitations in the kinds of HTML that VSCode can display, I think the SCDoc documentation has to be rendered slightly differently vs how it’s rendered now in order to be visible there. I recall this is mostly related to how links are written (I believe everything needs to be relative? I can’t recall exactly). If you do any work on this problem, it would definitely be shareable with the SuperCollider language server and VSCode support.

And, with that in mind, I’m happy to make changes to the SuperCollider language server if it would help with the Jupyter support? In particular, the LSC has pretty full support for auto-completion, and other introspection kinds of activities, and it probably wouldn’t be hard to write an adapter to Jupyter for this functionality.

1 Like

Integrating your language server would be awesome and is probably not too hard (?) since there is a Language Server integration for JupyterLab, see

How do you handle the communication between the language server and the interpreter? Doesn’t the LSP rely on TCP communication (which sc lacks?) or can you manage it via stdin/stdout or via OSC? Maybe we can discuss it @ Create LSP Branch · Issue #21 · capital-G/sc_kernel · GitHub ? :slight_smile:

Hi there!

Thanks for this great tool!

I have not tried to use this because my machine is (m1max).
Now I am investing my time to use it because some months have passed.

I have two questions:
1. {SinOsc.ar}.plot; plot(w) does not work. Is this incompatible with m1max Mac?

2. Is it not possible to use a long path?
It works fine if sclang is located in /Applications/SuperCollider.app/Contents/MacOS/.

However, my sclang is located in “/Users/prko/Dropbox/prko/__myDocs/Writings/Making Sound using Open Sources/mixed/dev - Bleeding edge/SuperCollider.app/Contents/MacOS/”.

I have changed the path in line 149 of the file ~/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py.
This works, but I get an error:

File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.

Is it possible to make the long path name work?

I am attaching whole errors:

Last login: Tue Nov 14 23:31:26 on ttys000
/Users/prko/anaconda3/bin/jupyter_mac.command ; exit;
(base) prko@prkoMBP2021 ~ % /Users/prko/anaconda3/bin/jupyter_mac.command ; exit;

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|
                       
Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[W 23:44:00.511 NotebookApp] Loading JupyterLab as a classic notebook (v6) extension.
[C 23:44:00.511 NotebookApp] You must use Jupyter Server v1 to load JupyterLab as notebook extension. You have v2.10.0 installed.
    You can fix this by executing:
        pip install -U "jupyter-server<2.0.0"
[I 23:44:01.154 NotebookApp] Serving notebooks from local directory: /Users/prko
[I 23:44:01.154 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 23:44:01.154 NotebookApp] http://localhost:8888/?token=11b6078c959f71fdb106ad863bca6d9df48efd47e79e5c61
[I 23:44:01.154 NotebookApp]  or http://127.0.0.1:8888/?token=11b6078c959f71fdb106ad863bca6d9df48efd47e79e5c61
[I 23:44:01.154 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 23:44:01.157 NotebookApp] 
    
    To access the notebook, open this file in a browser:
        file:///Users/prko/Library/Jupyter/runtime/nbserver-93284-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/?token=11b6078c959f71fdb106ad863bca6d9df48efd47e79e5c61
     or http://127.0.0.1:8888/?token=11b6078c959f71fdb106ad863bca6d9df48efd47e79e5c61
[I 23:44:08.927 NotebookApp] Creating new notebook in 
[I 23:44:09.979 NotebookApp] Kernel started: 5b044056-6d4b-454d-bc3e-3af4d3923203, name: sc_kernel
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[I 23:44:12.966 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[I 23:44:16.016 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[I 23:44:19.082 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[I 23:44:22.143 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[I 23:44:25.201 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
Traceback (most recent call last):
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/Users/prko/anaconda3/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 991, in launch_instance
    app.initialize(argv)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/application.py", line 113, in inner
    return method(app, *args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/ipykernel/kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/traitlets/config/configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 139, in __init__
    self.wrapper = self._sclang
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 158, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/sc_kernel/kernel.py", line 239, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 205, in __init__
    self._spawn(command, args, preexec_fn, dimensions)
  File "/Users/prko/anaconda3/lib/python3.10/site-packages/pexpect/pty_spawn.py", line 276, in _spawn
    raise ExceptionPexpect('The command was not found or was not ' +
pexpect.exceptions.ExceptionPexpect: The command was not found or was not executable: /Users/prko/Dropbox/prko/__myDocs/Writings/Making.
[W 23:44:28.260 NotebookApp] KernelRestarter: restart failed
[W 23:44:28.262 NotebookApp] Kernel 5b044056-6d4b-454d-bc3e-3af4d3923203 died, removing from map.
[W 23:45:10.000 NotebookApp] Timeout waiting for kernel_info reply from 5b044056-6d4b-454d-bc3e-3af4d3923203
[E 23:45:10.011 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 5b044056-6d4b-454d-bc3e-3af4d3923203)
[W 23:45:11.039 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1): Kernel does not exist: 5b044056-6d4b-454d-bc3e-3af4d3923203
[W 23:45:11.059 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1) 30.890000ms referer=None
[W 23:45:13.104 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1): Kernel does not exist: 5b044056-6d4b-454d-bc3e-3af4d3923203
[W 23:45:13.108 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1) 8.770000ms referer=None
[W 23:45:17.206 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1): Kernel does not exist: 5b044056-6d4b-454d-bc3e-3af4d3923203
[W 23:45:17.207 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1) 5.070000ms referer=None
[W 23:45:25.310 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1): Kernel does not exist: 5b044056-6d4b-454d-bc3e-3af4d3923203
[W 23:45:25.311 NotebookApp] 404 GET /api/kernels/5b044056-6d4b-454d-bc3e-3af4d3923203/channels?session_id=708c5e95110949dd8248fd9246f75b22 (::1) 5.030000ms referer=None

sc3 Jupyter kernels can be a greate option for tutorials.

2 Likes

I don’t have a M1, but if SuperCollider works i think this should work as well. At least you get some response from SuperCollider :slight_smile:

It looks like you forgot to assign w to the plot window, the following code is stated in the example and last time I tested it, it worked

w = {SinOsc.ar}.plot;
plot.(w);

It is possible to set the path of the sclang executable explicitly at runtime via an environment variable - check out the installation section of the docs @ GitHub - capital-G/sc_kernel: SuperCollider Kernel for Jupyter - either set the env variable via the .bashrc/.zshrc or set it before executing jupyter, so

SCLANG_PATH="/my/custom/sclang/path" jupyter lab

Nonetheless, it looks like you have not escaped the path properly as python wants to execute /Users/prko/Dropbox/prko/__myDocs/Writings/Making.

but instead it should be something like

/Users/prko/Dropbox/prko/__myDocs/Writings/Making Sound using Open Sources/mixed/dev - Bleeding edge/SuperCollider.app/Contents/MacOS/sclang


Indeed, this was also my main motivation, see e.g. Musikinformatik SoSe2021 — Musikinformatik SoSe2021 which also makes use of the jupyter book project which integrates nicely.

1 Like

Very cool. In order for Jupyter Notebooks to run on my machine, I have to do:

jupyter lab --app-dir /opt/homebrew/share/jupyter/lab

Maybe because the location of homebrew changed on the m1 macs?

Anyhow, when Jupyter Notebooks opens up, SC isn’t an option. I only have Python and Mojo. Any idea why this might be the case? I tried this:

SCLANG_PATH=/Applications/SuperCollider.app/Contents/MacOS/sclang jupyter lab --app-dir /opt/homebrew/share/jupyter/lab

in case it couldn’t find sclang, but I think it just isn’t finding the kernal.

Thanks,
Sam

It is perfect!
Thank you so much!

I misread the code in the image. Sorry about that! I thought about where the variable came from, but did not think that I had misread your code, really sorry for my stupid mistake!

In my home folder I found the hidden file “.zshrc”. I added the path as follows:


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/prko/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/prko/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/prko/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/prko/anaconda3/bin:$PATH"
    fi
    SCLANG_PATH="/Users/prko/Dropbox/prko/__myDocs/Writings/Making Sound using Open Sources/mixed/dev - Bleeding edge/SuperCollider.app/Contents/MacOS/sclang" Jupyter lab
fi
unset __conda_setup
# <<< conda initialize <<<

Now it works as expected!

I have also tested it on Ubuntu and Windows 11.

On Ubuntu it works perfectly without any modification! Perfectly!

However, I could not get it to work on Windows. It does not seem to be implemented, but I have described what I did because you seem to know:

  1. The following code should be run in Anaconda Prompt (not Command Prompt):

    pip3 install --upgrade sc-kernel
    
  2. I have modified the line 151 of the file %USERPROFILE%\anaconda3\Lib\site-packages\sc_kernelkernel.py as follows.

  • sclang_path = "C:\Program Files\SuperCollider-3.13.0\sclang.exe"
  • sclang_path = "C:/Program Files/SuperCollider-3.13.0/sclang.exe"

However, I received the following error messages when I tried each of them:

(base) C:\Users\prko>jupyter notebook

  _   _          _      _
 | | | |_ __  __| |__ _| |_ ___
 | |_| | '_ \/ _` / _` |  _/ -_)
  \___/| .__/\__,_\__,_|\__\___|
       |_|

Read the migration plan to Notebook 7 to learn about the new features and the actions to take if you are using extensions.

https://jupyter-notebook.readthedocs.io/en/latest/migrate_to_notebook7.html

Please note that updating to Notebook 7 might break some of your extensions.

[W 08:15:19.523 NotebookApp] Loading JupyterLab as a classic notebook (v6) extension.
[C 08:15:19.523 NotebookApp] You must use Jupyter Server v1 to load JupyterLab as notebook extension. You have v2.10.0 installed.
    You can fix this by executing:
        pip install -U "jupyter-server<2.0.0"
[I 08:15:21.669 NotebookApp] The port 8888 is already in use, trying another port.
[I 08:15:21.670 NotebookApp] The port 8889 is already in use, trying another port.
[I 08:15:21.670 NotebookApp] The port 8890 is already in use, trying another port.
[I 08:15:21.670 NotebookApp] The port 8891 is already in use, trying another port.
[I 08:15:21.671 NotebookApp] The port 8892 is already in use, trying another port.
[I 08:15:21.673 NotebookApp] Serving notebooks from local directory: C:\Users\prko
[I 08:15:21.674 NotebookApp] Jupyter Notebook 6.5.4 is running at:
[I 08:15:21.674 NotebookApp] http://localhost:8828/?token=5947cc58f47bf99c02bb451b8b8f41ec634a32cea9f579b1
[I 08:15:21.674 NotebookApp]  or http://127.0.0.1:8828/?token=5947cc58f47bf99c02bb451b8b8f41ec634a32cea9f579b1
[I 08:15:21.674 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:15:21.707 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/prko/AppData/Roaming/jupyter/runtime/nbserver-8608-open.html
    Or copy and paste one of these URLs:
        http://localhost:8828/?token=5947cc58f47bf99c02bb451b8b8f41ec634a32cea9f579b1
     or http://127.0.0.1:8828/?token=5947cc58f47bf99c02bb451b8b8f41ec634a32cea9f579b1
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
[I 08:15:34.159 NotebookApp] Creating new notebook in
[I 08:15:37.753 NotebookApp] Kernel started: e7979428-f4c8-403b-9f01-fefdf7af4366, name: sc_kernel
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.01s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[I 08:15:49.692 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.01s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[I 08:15:58.733 NotebookApp] KernelRestarter: restarting kernel (2/5), new random ports
0.03s - Debugger warning: It seems that frozen modules are being used, which may
0.04s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.01s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[I 08:16:07.764 NotebookApp] KernelRestarter: restarting kernel (3/5), new random ports
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[I 08:16:10.801 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[I 08:16:13.845 NotebookApp] KernelRestarter: restarting kernel (5/5), new random ports
0.00s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\__main__.py", line 5, in <module>
    IPKernelApp.launch_instance(kernel_class=SCKernel)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 991, in launch_instance
    app.initialize(argv)
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\application.py", line 113, in inner
    return method(app, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 704, in initialize
    self.init_kernel()
  File "C:\Users\prko\anaconda3\Lib\site-packages\ipykernel\kernelapp.py", line 552, in init_kernel
    kernel = kernel_factory(
             ^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\traitlets\config\configurable.py", line 552, in instance
    inst = cls(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 139, in __init__
    self.wrapper = self._sclang
                   ^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 159, in _sclang
    self.__sclang = ScREPLWrapper(f"{self._sclang_path} -i jupyter")
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\prko\anaconda3\Lib\site-packages\sc_kernel\kernel.py", line 240, in __init__
    cmd = pexpect.spawn(cmd_or_spawn, encoding="utf-8")
          ^^^^^^^^^^^^^
AttributeError: module 'pexpect' has no attribute 'spawn'
[W 08:16:19.879 NotebookApp] KernelRestarter: restart failed
[W 08:16:19.880 NotebookApp] Kernel e7979428-f4c8-403b-9f01-fefdf7af4366 died, removing from map.
[W 08:16:37.882 NotebookApp] Timeout waiting for kernel_info reply from e7979428-f4c8-403b-9f01-fefdf7af4366
[E 08:16:37.887 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366)
[W 08:16:38.925 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:16:38.938 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 14.000000ms referer=None
[W 08:16:40.951 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:16:40.953 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 4.140000ms referer=None
[W 08:16:44.981 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:16:44.984 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 5.000000ms referer=None
[W 08:16:53.020 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:16:53.024 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 6.000000ms referer=None
[W 08:17:09.082 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:17:09.087 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 6.000000ms referer=None
[I 08:17:37.090 NotebookApp] Saving file at /Untitled4.ipynb
C:\Users\prko\anaconda3\Lib\site-packages\nbformat\__init__.py:129: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
  validate(nb)
C:\Users\prko\anaconda3\Lib\site-packages\notebook\services\contents\manager.py:353: MissingIDFieldWarning: Code cell is missing an id field, this will become a hard error in future nbformat versions. You may want to use `normalize()` on your notebooks before validations (available since nbformat 5.1.4). Previous versions of nbformat are fixing this issue transparently, and will stop doing so in the future.
  validate_nb(model['content'])
[W 08:17:41.171 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1): Kernel does not exist: e7979428-f4c8-403b-9f01-fefdf7af4366
[W 08:17:41.174 NotebookApp] 404 GET /api/kernels/e7979428-f4c8-403b-9f01-fefdf7af4366/channels?session_id=4f1c889c6b1d4e33979415e2cd3d2f30 (::1) 14.580000ms referer=None

Thanks again for your great contribution. Hope it works on Windows too!

sc3 has a GNUPlot quark, which can integrate well with notebooks. But how realtime audio (play and stop etc) works in jupyter? Just like a normal ide? I hae used both notmal python notebook and experimental ones like iHaskell (which is not trivial to get it to work). Maybe that’s a trend to include more languages as jupyter kernels.

Well, I found communicating with the sclang process is not really trivial and pexpect really helped me but it does not really work under windows as windows disregards the Unix standard, see API Overview — Pexpect 4.8 documentation - also look out that the escaping of windows paths in Python needs some pre-caution :slight_smile:

As I don’t have any Windows machine accessible I need to rely on contributions here :slight_smile:

Windows seems more and more abandonware for CLI tools these days it seems the proper way is to use WSL2? But I am unsure if WSL2 can access the sound card, so using SC within it may not be really interesting after all.

Yes.
The main problem I faced more is that sclang is a pure async language, much like the event loop in JavaScript, which means I will not be sure when something finished executing and who requested that response - so I wrap each cell in a function which wraps a unique string around the result so it is possible to identify when something finished, and which also makes it possible to attach the result of a cell to a cell.

2 Likes

Jupyter kernels work quite well in vscode. I prefer to use them that way, btw.

1 Like

Even if SuperCollider is not installed in the default location, you can use the sclang kernel for Jupyter without editing the kernel.py file, just by creating a symbolic link in a terminal window:

ln -s "/..../SuperCollider.app" "/Applications/SuperCollider.app"

In my case:

ln -s /Users/prko/Dropbox/prko/__myDocs/Writings/Making\ Sound\ using\ Open\ Sources/mixed/dev\ -\ Bleeding\ edge/SuperCollider.app /Applications/SuperCollider.app