I'm trying to get the path of the current Jupyter notebook, while using VSCode.
I tried all of the solutions in this post: How do I get the current IPython / Jupyter Notebook name, but none of them are working in VSCode. I can get them to work through JupyterLab.
When I try the solutions that involve a %%javascript magic command, that cell will execute successfully, but the kernel is not updated with the variable containing the notebook name.
Update: I think the issue is how my VSCode is handling the %%javascript magic output. With nodejs in my venv, I can get the code below to display the expected output. %%script node console.log("hello") However, if I try the same with %% javascript, I get <IPython.core.display.Javascript object> as the output, ie: %%javascript console.log("hello")
Please try with this fix. This fix may vary from OS to OS.
import os
os.path.basename(globals()['__vsc_ipynb_file__'])