Get Jupyter notebook name

孤人 提交于 2019-12-13 13:32:41

问题


I want to store currently running Jupyter notebook name in python variable. I create 2 cells

from IPython.display import display,Javascript 
Javascript('IPython.notebook.kernel.execute("notebook_name = " + "\'"+IPython.notebook.notebook_name+"\'");')

and

notebook_name

This works fine if I execute cells one after another, but I mostly execute cells with "run all cells" command, and in this case I get the error:

NameError: name 'notebook_name' is not defined

I get the same error if I unite previous 2 cells into 1 cell. I believe this is due to synchronization between python and JavaScript. Any help is appreciated.

来源:https://stackoverflow.com/questions/50633415/get-jupyter-notebook-name

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!