Closed gianfa closed 1 month ago
If you are using IPython, IPython has the notion of profiles, which are for this kind of thing. Profiles can load different configurations, including startup scripts (startup scripts can be placed in $(ipython profile locate [name])/startup/
). The ipython kernel install
command which installs kernelspecs lets you specify the profile to load.
For example, to create a profile called sample
, add some startup scripts, and register it as a kernel:
# create new profile, named 'sample'
ipython profile create sample
# add any scripts to the `startup` directory, which load on IPython start
cp myscript.py $(ipython profile locate sample)/startup/myscript.py
# register this profile as its own kernel
ipython kernel install --sys-prefix --name sample-profile --profile sample
oh, I see. It actually sounds like what I was looking for, but I didn't quite understand this segregation between profiles yet. Thanks so much for the clear example! (and for the great work behind jupyter!).
Hello, it would be nice if one could define some code to execute at startup of a specific kernel, in a more elegant way. Currently, to my knowledge, the only direct way is by modifying the argv of the kernel.json associated with the specific kernel. This has the downside of being a bit hacky.
It would be nice to have a (yet another) config file, or an entrypoint in jupyter_lab_config.py. For example:
Or, via CLI:
Alternatively, a simple and clear tutorial on the subject might also be fine :)
Thank you for the great work behind Jupyter!