[IPython-dev] Create New Notebook from Command-line

Matthias BUSSONNIER bussonniermatthias at gmail.com
Fri Dec 5 03:57:54 EST 2014


Hi Andrew. 

Base on a Fernando example would the following python snippet suit you ?

import IPython.nbformat as nbf
nb = nbf.v4.new_notebook()
text = "This is an auto-generated notebook"
nb['cells'] = [ nbf.v4.new_markdown_cell(text)]
nb['cells'].append(nbf.v4.new_code_cell('#'+text))
fname = 'test.ipynb'

with open(fname, 'w') as f:
    nbf.write(nb, f, 4)

-- 
M

Le 4 déc. 2014 à 20:41, Andrew Gibiansky a écrit :

> Hey all,
> 
> I like to use `ipython notebook MyNotebook.ipynb` to open an ipynb file. However, if I use this on a file that doesn't exist, I get: 
> 
> 2014-12-04 11:39:39.952 [NotebookApp] CRITICAL | No such file or directory: /Users/person/MyNotebook.ipynb
> 
> How can I programmatically create a new notebook so that `ipython notebook TheNB.ipynb` will work? This must be either command-line commands or Python code, but looking into ipython flags there doesn't seem to be anything. Does anyone have any suggestions? ("Press the button" does not work in my case)
> 
> thanks!
> Andrew
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev




More information about the IPython-dev mailing list