Build a UI with Euporie to Run and Edit Jupyter Notebooks

Euporie is a text-based user interface for running and editing Jupyter notebooks.

Install

Euporie is on pypi, so can be installed using pip or pipx:

# install inside a virtualenv
pip install euporie

# install globally
pipx install euporie

You may wish to install some optional python dependencies to render images and HTML tables :

pip install euporie[html-mtable,images-timg]

Screenshots

A text-based user interface for running and editing Jupyter notebooksA text-based user interface for running and editing Jupyter notebooksA text-based user interface for running and editing Jupyter notebooksA text-based user interface for running and editing Jupyter notebooksA text-based user interface for running and editing Jupyter notebooks

Features

  • Execute notebooks in the terminal
  • Autocompletion in code cells
  • Rich output support, including:
    • Markdown
    • Tables
    • Images
  • Open multiple notebooks side-by-side
  • Good performance with large notebook files

Image Support

Euporie will attempt to render images in the best possible way it can. The following methods are supported:

Sixel

If supported by your terminal, euporie can show graphical images in cell outputs
This requires one of the following:

imagemagik
timg
teimpy

Kitty's terminal image protocol

If your terminal supports kitty's terminal graphics protocol, euporie will use it to render images

Ansi art

This requires one of the following:

timg
catimg
icat
timg
tiv
viu
img2unicode
jp2a
img2txt

The kitty & sixel image rendering methods will fall back to ansi art images when rendering images in partially obscured cells, to prevent clipped images destroying the user interface.

For SVG support, cairosvg or imagemagik are required.

HTML Support

Euporie will attempt to render HTML outputs. This requires one of the following:

w3m
elinks
lynx
links
mtable

Note: only HTML tables will be displayed if mtable is used

If none of these commands are found in your $PATH, the plain text representation will be used.

Usage

usage: euporie [-h] [--verion] [--dump | --no-dump] [--dump-file [Path]]
               [--page | --no-page] [--key-map {emacs,vi}]
               [--run-after-external-edit bool] [--max-notebook-width int]
               [--background-pattern {0,1,2,3,4}] [--background-character str]
               [--line-numbers | --no-line-numbers] [--syntax-theme str]
               [Path ...]

positional arguments:
  Path                  List of file names to open

optional arguments:
  -h, --help            show this help message and exit
  --verion, -V          show program's version number and exit
  --dump, --no-dump     Output formatted file to display or file
  --dump-file [Path]    Output path when dumping file
  --page, --no-page     Pass output to pager
  --key-map {emacs,vi}  Key-binding mode for text editing
  --run-after-external-edit bool
                        Run cells after editing externally
  --max-notebook-width int
                        Maximum width of notebooks
  --background-pattern {0,1,2,3,4}
                        The background pattern to use
  --background-character str
                        Character for background pattern
  --line-numbers, --no-line-numbers
                        Show or hide line numbers
  --syntax-theme str    Syntax higlighting theme

Key Bindings

Key BindingCommand
Application 
ctrl-nCreate a new notebook file
ctrl-oOpen file
ctrl-wClose the current file
ctrl-qQuit euporie
ctrl-sSave current file
Navigation 
tabFocus next element
shift-tabFocus previous element
[Scroll up
]Scroll down
ctrl-up / homeGo to first cell
pageupGo up 5 cells
up / kGo up one cell
down / jGo down one cell
pagedownGo down 5 cells
ctrl-down / endGo to last cell
Notebook 
aAdd new cell above
bAdd new cell below
d dDelete current cell
xCut current cell
cCopy current cell
vPaste copied cell
mChange cell to markdown
yChange cell to code
rChange cell to raw
lToggle line numbers
eEdit cell in $EDITOR
enterEnter cell edit mode
escapeExit cell edit mode*
escape escapeExit cell edit mode quickly
ctrl-enter / ctrl-eRun cell**
shift-enter / ctrl-rRun then select next cell**
Edit Mode 
ctrl-fFind
ctrl-gFind Next
ctrl-zUndo
ctrl-dDuplicate line
tabIndent
shift-tabUnindent
ctrl-cCopy
ctrl-xCut
ctrl-vPaste

* There is a slight delay detecting an escape key-event. To exit edit mode quickly, double-press the escape key.

** These entries require your terminal to support CSI-u mode. If your terminal does not support this, it may be possible to work around this by remapping the keys in your terminal emulator - see below).

When in edit mode, emacs style key-bindings apply.

Key Remapping

By default, VT100 terminal emulators do not distinguish between Enter, Ctrl + Enter & Shift + Enter. In order to work around this, it is possible to re-map these key bindings so they produce the escape code of another key. To replicate the Ctrl + Enter & Shift + Enter of Jupyter, you will need to remap the following shortcuts in your terminal:

Key CombinationOutput
Ctrl + EnterCtrl + F20
Shift + EnterF21

xterm

Add the following to your ~/.Xresources

*.vt100.translations: #override \n\
    Ctrl <Key>Return: string("\033\[19;6~") \n\
    Shift <Key>Return: string("\033\[20;2~") \n\

konsole

In the menu, navigate to:

Settings -> Edit Current Profile -> Keyboard -> Edit

Change the existing entry for Return+Shift to Return+Shift+Ctrl (or whatever you prefer), then add the following entries:

Key combinationOutput
Return+Ctrl\E\[19;6~
Return+Shift\E\[20;2~

Roadmap

  • Add ability to dump formatted notebooks
  • Add command line argument parsing
  • Render outputs asynchronously in a separate thread
  • Upstream markdown tables in rich
  • Cell attachments
  • LaTeX
  • Widgets

Download Details: 

 

Author: joouha

Official Website: https://github.com/joouha/euporie 


 

2 Likes4.20 GEEK