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
5 Answers
Answers 1
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.
Answers 2
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)
Answers 3
Sadly, there is no such way. The reason is that the jupyter runs something like a server on your computer, as you can tell from the "localhost" part of the URL. The good news is that if the server is already running, then as the inspect-element utility reveals that the pages are just web pages.
The commands are actually executed on anaconda application console which only seem to contain functionality for launching modules etc.
However you can use a shortcut link on your desktop or something to go to the notebook of interest (assuming jupyter notebook is already running)
I have no clue how you would create a notebook from a script though...
Answers 4
Jupyter will start running on Tornado server on localhost. The link is something like http://localhost/Tree When you open a notebook, this is done in another page. You can try to write a batch script to call kupyter notebok, then call your browser with the address to your notebook. I take it that if the notebook doesn't exist, is not created, then it will not work (the page is note created, it cannot be opened).
Answers 5
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'
Putting it all together
create-notebook my_notebook && jupyter notebook my_notebook.ipynb
0 comments:
Post a Comment