Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the current IPython / Jupyter Notebook name

I am trying to obtain the current NoteBook name when running the IPython notebook. I know I can see it at the top of the notebook. What I am after something like

currentNotebook = IPython.foo.bar.notebookname() 

I need to get the name in a variable.

like image 363
Tooblippe Avatar asked Sep 22 '12 13:09

Tooblippe


People also ask

How do I find my IPython version Jupyter Notebook?

To check the Python version in your Jupyter notebook, first import the python_version function with “ from platform import python_version “. Then call the function python_version() that returns a string with the version number running in your Jupyter notebook such as "3.7. 11" .

Is IPython notebook and Jupyter Notebook same?

Jupyter Notebook (formerly IPython Notebook) is a web-based interactive computational environment for creating, executing, and visualizing Jupyter notebooks.

What is the file name for Jupyter Notebook?

When you use the Jupyter Notebook dashboard menu to rename Jupyter Notebook files (. ipynb), a new window will open in which you can type the new name of the file.

Does Jupyter Notebook come with IPython?

The name, Jupyter, comes from the core supported programming languages that it supports: Julia, Python, and R. Jupyter ships with the IPython kernel, which allows you to write your programs in Python, but there are currently over 100 other kernels that you can also use.


1 Answers

adding to previous answers,

to get the notebook name run the following in a cell:

%%javascript IPython.notebook.kernel.execute('nb_name = "' + IPython.notebook.notebook_name + '"') 

this gets you the file name in nb_name

then to get the full path you may use the following in a separate cell:

import os nb_full_path = os.path.join(os.getcwd(), nb_name) 
like image 182
Mahmoud Elagdar Avatar answered Oct 06 '22 08:10

Mahmoud Elagdar