summaryrefslogtreecommitdiff
path: root/content/blog/jupyterlab-notebook-file-oneliner/index.rst
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2025-06-30 15:40:37 +0200
committerjaseg <git@jaseg.de>2025-06-30 15:40:37 +0200
commit61c112870d029ad5ec0510b105d157b8ffb86f55 (patch)
tree575c4f36b6da08196739ea364e463b4d3a52383b /content/blog/jupyterlab-notebook-file-oneliner/index.rst
parent322eddf574e8b5bd01f0b5ce553bafa6ce10a774 (diff)
parent0d45de162ce253f7c18c4c60d013ab502a3dbb1f (diff)
downloadblog-deploy.tar.gz
blog-deploy.tar.bz2
blog-deploy.zip
deploy.py auto-commitdeploy
Diffstat (limited to 'content/blog/jupyterlab-notebook-file-oneliner/index.rst')
-rw-r--r--content/blog/jupyterlab-notebook-file-oneliner/index.rst21
1 files changed, 0 insertions, 21 deletions
diff --git a/content/blog/jupyterlab-notebook-file-oneliner/index.rst b/content/blog/jupyterlab-notebook-file-oneliner/index.rst
deleted file mode 100644
index 5a543de..0000000
--- a/content/blog/jupyterlab-notebook-file-oneliner/index.rst
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: "Getting the .ipynb Notebook File Location From a Running Jupyter Lab Notebook"
-date: 2025-06-29T23:42:00+01:00
-summary: >
- If you need to get the path of the ipynb file in a running #Jupyter notebook, this one-liner will do the trick. It
- seems chatgpt is confused, and a bunch of other approaches on the web look fragile and/or unnecessarily complex to
- me.
----
-
-If you need to get the path of the ipynb file in a running #Jupyter notebook, this one-liner will do the trick. It seems
-chatgpt is confused, and a bunch of other approaches on the web look fragile and/or unnecessarily complex to me.
-
-.. code:: python
-
- import sys
- Path(json.loads(Path(sys.argv[-1]).read_bytes())['jupyter_session'])
-
-The way this works is that for each notebook, jupyter starts a python "kernel" process that actually runs the notebook's
-code. That kernel gets a json file with info on the notebook's location on the disk passed through its command line.
-Since we're running code in that exact python process, we can just grab that json file from sys.argv, and read it
-ourselves.