The command jupyter notebook will open the Jupyter directory tree page where you can create a ipynb file.
Is there a way to skip that page and create and open the ipynb file directly on the browser?
I was thinking something like jupyter notebook mynotebook.ipynb
Open notebook in browser
jupyter notebook <notebook>.ipynb
Create empty, minimal notebook:
"""create-notebook.py
Creates a minimal jupyter notebook (.ipynb)
Usage: create-notebook <notebook>
"""
import sys
from notebook import transutils as _
from notebook.services.contents.filemanager import FileContentsManager as FCM
try:
notebook_fname = sys.argv[1].strip('.ipynb')
except IndexError:
print("Usage: create-notebook <notebook>")
exit()
notebook_fname += '.ipynb' # ensure .ipynb suffix is added
FCM().new(path=notebook_fname)
Alias create-notebook script:
alias create-notebook='python $(pwd)/create-notebook.py'
create-notebook my_notebook && jupyter notebook my_notebook.ipynb
This can't be the most desirable method. Maybe there's an option native to Jupyter or the extensions, but I haven't come across one, nor have I come across the need to do this. The documentation suggests the developers are encouraging users to land at the dashboard.
Start with an empty notebook Untitled.ipynb. To generate it, save the default file that is created when you create a new notebook from the jupyter dashboard. This empty notebook will be used as a template for creating new, empty notebooks at the command line. The contents of Untitled.ipynb for me, jupyter version 4.4.0, look like this:
$ cat Untitled.ipynb
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 2
}
The file contains the bare minimum needed to launch a notebook using jupyter notebook Untitled.ipynb (and eventually mynotebook.ipynb), any less and it will raise a NotJSONError. You can add some metadata to the template if you want to include a default kernel.
From here, use command substitution to open a new, empty notebook from the command line where Untitled.ipynb is the path to the template notebook created above and mynotebook.ipynb is the name of the notebook you wish to create:
$ jupyter notebook $(cat Untitled.ipynb >mynotebook.ipynb && echo mynotebook.ipynb)
You may try below command.
jupyter nbconvert --to notebook --execute mynotebook.ipynb
According to Jupyter nbconvert manual below, nbconvert with --execute command supports running a notebook.