Lets you view, edit and execute Jupyter Notebooks in the terminal.

Related tags

CLI Tools nbterm
Overview

Build Status Code style: black

nbterm

Lets you view, edit and execute Jupyter Notebooks in the terminal.

Key bindings

There are two modes: cell mode, and notebook mode.

  • enter: enter the cell mode, allowing to modify the content of the cell.
  • esc: exit the cell mode and enter the notebook mode.

When in notebook mode:

  • up and down arrows: navigate through cells.
  • ctrl-i: insert a new cell before the current one.
  • ctrl-j: insert a new cell after the current one.
  • ctrl-o: set the cell type to Code.
  • ctrl-n: set the cell type to Markdown.
  • ctrl-l: clear the output of the cell.
  • ctrl-e: execute the cell and stay on it.
  • ctrl-r: execute the cell and move to the next one.
  • ctrl-s: save the notebook.
  • ctrl-q: exit the application.
Comments
  • Previous outputs included when notebook run from the command line

    Previous outputs included when notebook run from the command line

    When I use "nbterm --run foo.ipynb" to execute a notebook, any cell outputs that are currently in the file are included in "foo_run.ipynb". New outputs are just appened to old outputs, with execution counts that start over from 1. I would think nbterm would behave like Jupyter, where a new kernel erases old outputs.

    opened by conery 10
  • Ctrl-E doesn't work for me

    Ctrl-E doesn't work for me

    I really like the idea of this!

    However I'm having trouble getting nbterm to execute the contents of cells. I can press enter, enter something in the cell, like print(100) then press ESC to go back to command mode.

    But when I then push Ctrl-E or Ctrl-R, nothing happens. No error message, nothing. Other key bindings (such as Ctrl-Q to quit) do work. Am I overlooking something?

    • Debian testing
    • Tilix terminal (based on vte like gnome-terminal). I've checked and Ctrl-E does send '\x05' correctly.
    • Python 3.9.2
    • nbterm 0.0.7 installed in a venv, using pip3 install nbterm
    opened by vmedea 9
  • Runtime Warning

    Runtime Warning

    Thanks for writing this great tool!

    I get the following warning when i open the notebook. Any idea?

    C:\Users\asharaf\AppData\Local\ESRI\conda\envs\arcgispro-py3-clone\lib\site-packages\zmq\_future.py:679: RuntimeWarning: Proactor event loop does not implement add_reader family of methods required for zmq. Registering an additional selector thread for add_reader support via tornado. Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.       
      self._get_loop()   
    

    image

    opened by azinsharaf 7
  • installation error

    installation error

    Hello, here I got the following error when I want to run the app. Nbterm runs but is not functional.

      File "/home/***/.local/lib/python3.8/site-packages/kernel_driver/driver.py", line 98, in start
        self.kernel_process = await launch_kernel(
      File "/home/***/.local/lib/python3.8/site-packages/kernel_driver/connect.py", line 73, in launch_kernel
        p = await asyncio.create_subprocess_exec(
      File "/usr/lib/python3.8/asyncio/subprocess.py", line 236, in create_subprocess_exec
        transport, protocol = await loop.subprocess_exec(
      File "/usr/lib/python3.8/asyncio/base_events.py", line 1630, in subprocess_exec
        transport = await self._make_subprocess_transport(
      File "/usr/lib/python3.8/asyncio/unix_events.py", line 197, in _make_subprocess_transport
        transp = _UnixSubprocessTransport(self, protocol, args, shell,
      File "/usr/lib/python3.8/asyncio/base_subprocess.py", line 36, in __init__
        self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
      File "/usr/lib/python3.8/asyncio/unix_events.py", line 789, in _start
        self._proc = subprocess.Popen(
      File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    
    Exception [Errno 2] No such file or directory: 'python'
    Press ENTER to continue...
    

    Thanks for giving me some hint.

    opened by Shahin-rmz 7
  • Nbterm asks for python while it should ask for python3 IMHO

    Nbterm asks for python while it should ask for python3 IMHO

    I removed python link on my computer so I have to run python2 or python3 to avoid mistake. Could you look for python3 instead of python?

    Exception [Errno 13] Permission denied: 'python'

    opened by oricou 6
  • Import Error from prompt_toolkit

    Import Error from prompt_toolkit

    # pip3 install nbterm
    ...
      Downloading prompt_toolkit-3.0.18-py3-none-any.whl (367 kB)
    ...
    
    % nbterm
    ...
    File "/usr/local/lib/python3.8/dist-packages/nbterm/notebook.py", line 8, in <module>
      from prompt_toolkit.layout import ScrollablePane
    ImportError: cannot import name 'ScrollablePane' from 'prompt_toolkit.layout'  
    

    I use Linux Mint 20 and Python 3.8.5.

    opened by oricou 6
  • Error at start

    Error at start

    Hi, when I run nbterm I have

    Unhandled exception in event loop:
      File "/home/aborruso/.local/lib/python3.9/site-packages/kernel_driver/driver.py", line 96, in start
        self.kernel_process = await launch_kernel(
      File "/home/aborruso/.local/lib/python3.9/site-packages/kernel_driver/connect.py", line 73, in launch_kernel
        p = await asyncio.create_subprocess_exec(
      File "/usr/lib/python3.9/asyncio/subprocess.py", line 236, in create_subprocess_exec
        transport, protocol = await loop.subprocess_exec(
      File "/usr/lib/python3.9/asyncio/base_events.py", line 1661, in subprocess_exec
        transport = await self._make_subprocess_transport(
      File "/usr/lib/python3.9/asyncio/unix_events.py", line 197, in _make_subprocess_transport
        transp = _UnixSubprocessTransport(self, protocol, args, shell,
      File "/usr/lib/python3.9/asyncio/base_subprocess.py", line 36, in __init__
        self._start(args=args, shell=shell, stdin=stdin, stdout=stdout,
      File "/usr/lib/python3.9/asyncio/unix_events.py", line 789, in _start
        self._proc = subprocess.Popen(
      File "/usr/lib/python3.9/subprocess.py", line 947, in __init__
        self._execute_child(args, executable, preexec_fn, close_fds,
      File "/usr/lib/python3.9/subprocess.py", line 1819, in _execute_child
        raise child_exception_type(errno_num, err_msg, err_filename)
    
    Exception [Errno 2] No such file or directory: 'python'
    

    Thank you

    opened by aborruso 5
  • no module named nbterm

    no module named nbterm

    Hi, after python setup.py install I get ——> nbterm Traceback (most recent call last): File "/home/guido/anaconda3/bin/nbterm", line 33, in sys.exit(load_entry_point('nbterm==0.0.2', 'console_scripts', 'nbterm')()) File "/home/guido/anaconda3/bin/nbterm", line 25, in importlib_load_entry_point return next(matches).load() File "/home/guido/anaconda3/lib/python3.8/importlib/metadata.py", line 77, in load module = import_module(match.group('module')) File "/home/guido/anaconda3/lib/python3.8/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 961, in _find_and_load_unlocked File "", line 219, in _call_with_frames_removed File "", line 1014, in _gcd_import File "", line 991, in _find_and_load File "", line 973, in _find_and_load_unlocked ModuleNotFoundError: No module named 'nbterm'

    when am I missing here. Thanks

    opened by guidov 5
  • Use nbformat instead of raw json to create/read/save notebooks

    Use nbformat instead of raw json to create/read/save notebooks

    While it's great that Jupyter notebooks are pure JSON files, I suggest using the nbformat read/write API instead of pure JSON. In practice, your format.py is gradually reinventing nbformat, I think it will be both safer and more productive to reuse nbformat itself.

    opened by fperez 4
  • Release 0.0.13

    Release 0.0.13

    Hello David,

    I'm offering You small changes to nbterm. It's just a few keys mapping. Feel free to scratch the whole or accept the changes. Some of the additions are:

    • support for php, c, java, javascript kernels
    • additional j,k vi-like mappings in command mode
    • basci ctrl-f search (currently opening dialog in external editor)
    • n, ctrl-n search for the string forward, backwards
    • m, - mark the cell
    • ', - go to marked cell
    • ctrl-p - run all cells
    • some info to readme regarding other kernels
    • that's about it

    Thank You for You great work and have a nice day

    opened by mtatton 3
  • Incompatibility with Click 8

    Incompatibility with Click 8

    nbterm depends on the library 'click' through the library 'typer'. Right now there is a problem with typer calling click.

    For those users installing nbterm with conda-forge, downgrade click as suggested in https://github.com/tiangolo/typer/issues/278

    opened by dprada 3
  • AttributeError: 'NoneType' object has no attribute 'start'

    AttributeError: 'NoneType' object has no attribute 'start'

    I have installed nbterm 0.0.13 using pip.

    I have a notebook test.ipynb which consists of a single cell (1+1).

    I am trying to run the notebook in batch mode using nbterm --run test.ipynb which gives the following error:

    ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
    │ /private/tmp/test/env/lib/python3.9/site-packages/nbterm/nbterm.py:73 in main                    │
    │                                                                                                  │
    │   70 │   )                                                                                       │
    │   71 │   if run:                                                                                 │
    │   72 │   │   assert no_kernel is not True                                                        │
    │ ❱ 73 │   │   asyncio.run(nb.run_all())                                                           │
    │   74 │   │   if save_path is None:                                                               │
    │   75 │   │   │   directory = notebook_path.parent                                                │
    │   76 │   │   │   prefix = str(directory / f"{notebook_path.stem}_run")                           │
    │                                                                                                  │
    │ ╭───────────────────────────── locals ─────────────────────────────╮                             │
    │ │    kernel_cwd = PosixPath('.')                                   │                             │
    │ │            nb = <nbterm.notebook.Notebook object at 0x102216460> │                             │
    │ │     no_kernel = None                                             │                             │
    │ │ notebook_path = PosixPath('test.ipynb')                          │                             │
    │ │        prefix = 'Untitled'                                       │                             │
    │ │           run = True                                             │                             │
    │ │     save_path = None                                             │                             │
    │ │          test = None                                             │                             │
    │ │       version = None                                             │                             │
    │ ╰──────────────────────────────────────────────────────────────────╯                             │
    │                                                                                                  │
    │ /opt/homebrew/Caskroom/miniforge/base/envs/kostrykin2021-m1/lib/python3.9/asyncio/runners.py:44  │
    │ in run                                                                                           │
    │                                                                                                  │
    │   41 │   │   events.set_event_loop(loop)                                                         │
    │   42 │   │   if debug is not None:                                                               │
    │   43 │   │   │   loop.set_debug(debug)                                                           │
    │ ❱ 44 │   │   return loop.run_until_complete(main)                                                │
    │   45 │   finally:                                                                                │
    │   46 │   │   try:                                                                                │
    │   47 │   │   │   _cancel_all_tasks(loop)                                                         │
    │                                                                                                  │
    │ ╭──────────────────────────────── locals ────────────────────────────────╮                       │
    │ │ debug = None                                                           │                       │
    │ │  loop = <_UnixSelectorEventLoop running=False closed=True debug=False> │                       │
    │ │  main = <coroutine object Notebook.run_all at 0x1021f6ac0>             │                       │
    │ ╰────────────────────────────────────────────────────────────────────────╯                       │
    │                                                                                                  │
    │ /opt/homebrew/Caskroom/miniforge/base/envs/kostrykin2021-m1/lib/python3.9/asyncio/base_events.py │
    │ :642 in run_until_complete                                                                       │
    │                                                                                                  │
    │    639 │   │   if not future.done():                                                             │
    │    640 │   │   │   raise RuntimeError('Event loop stopped before Future completed.')             │
    │    641 │   │                                                                                     │
    │ ❱  642 │   │   return future.result()                                                            │
    │    643 │                                                                                         │
    │    644 │   def stop(self):                                                                       │
    │    645 │   │   """Stop running the event loop.                                                   │
    │                                                                                                  │
    │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │
    │ │   future = <Task finished name='Task-1' coro=<Notebook.run_all() done, defined at            │ │
    │ │            /private/tmp/test/env/lib/python3.9/site-packages/nbterm/notebook.py:117>         │ │
    │ │            exception=AttributeError("'NoneType' object has no attribute 'start'")>           │ │
    │ │ new_task = True                                                                              │ │
    │ │     self = <_UnixSelectorEventLoop running=False closed=True debug=False>                    │ │
    │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │
    │                                                                                                  │
    │ /private/tmp/test/env/lib/python3.9/site-packages/nbterm/notebook.py:118 in run_all              │
    │                                                                                                  │
    │   115 │   │   await self.current_cell.run()                                                      │
    │   116 │                                                                                          │
    │   117 │   async def run_all(self):                                                               │
    │ ❱ 118 │   │   await self.kd.start()                                                              │
    │   119 │   │   for i in range(len(self.cells)):                                                   │
    │   120 │   │   │   await self.run_cell(i)                                                         │
    │   121                                                                                            │
    │                                                                                                  │
    │ ╭──────────────────────── locals ─────────────────────────╮                                      │
    │ │ self = <nbterm.notebook.Notebook object at 0x102216460> │                                      │
    │ ╰─────────────────────────────────────────────────────────╯                                      │
    ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
    AttributeError: 'NoneType' object has no attribute 'start'
    

    Why isn't this working as expected and what does the error mean?

    opened by kostrykin 1
  • Markdown text wrapping cuts off

    Markdown text wrapping cuts off

    When editing a Markdown cell inside nbterm, I can insert line breaks so that the content fits on screen. image

    However, when viewing a Markdown cell, text wrapping always cuts off a portion of the text, as long as it overflows. This is independent of the width of the terminal emulator: resizing it does not help.

    image

    On a related note, Markdown headers, which are center-aligned, are often cut off as well. image

    Using Gnome Terminal on Ubuntu 22.04, and Python 3.10.4.

    opened by jjeffrey 3
  • tab key not working

    tab key not working

    Hi, Thank you for your great work! I found the tab key not working in edition mode. I have to type 4 spaces instead. I am not sure the reason, but for other popular terminal editors (vim, neovim, nano) my tab key works normally.

    My environment: Operation System: Ubuntu 18.04 Python 3.8 (pip), nbterm 0.0.12 Terminal: terminator

    opened by Eralien 1
  • cell type

    cell type "raw" not handled

    nbterm breaks if a notebook contains cells of type raw. In the function set_input_readonly(), only cells of types markdown and code are used to set the text variable, so if a cell of type raw is encountered, the text variable will be uninitialized in line 181 of cell.py.

    opened by heseber 1
  • Not clear how to run set the kernel for a notebook to C++

    Not clear how to run set the kernel for a notebook to C++

    Hi,

    I was trying to use a C++ kernel with nbterm. I have already installed the xeus-cling kernel and have it working with my jupyter notebook environment.

    I see the "--kernel-cwd" option but nothing that would allow me to specify the kernel name.

    Looking through the code I see that kernel_name is a parameter to the KernelDriver initialization but I can't seem to figure out how to specify the C++ kernel.

    Thanks!

    opened by armaninspace 2
Owner
David Brochart
Scientific Software Engineer at @QuantStack
David Brochart
Module for converting 2D Python lists to fancy ASCII tables. Table2Ascii lets you display pretty tables in the terminal and on Discord.

table2ascii Module for converting 2D Python lists to a fancy ASCII/Unicode tables table2ascii ?? Installation ??‍?? Usage Convert lists to ASCII table

Jonah Lawrence 40 Jan 3, 2023
Euporie is a text-based user interface for running and editing Jupyter notebooks

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

null 781 Jan 1, 2023
AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

AWS Interactive CLI - Allows you to execute a complex AWS commands by chaining one or more other AWS CLI dependency

Rafael Torres 2 Dec 10, 2021
The Pythone Script will generate a (.)sh file with reverse shell codes then you can execute the script on the target

Pythone Script will generate a (.)sh file with reverse shell codes then you can execute the script on the targetPythone Script will generate a (.)sh file with reverse shell codes then you can execute the script on the target

Boy From Future 15 Sep 16, 2022
Gamestonk Terminal is an awesome stock and crypto market terminal

Gamestonk Terminal is an awesome stock and crypto market terminal. A FOSS alternative to Bloomberg Terminal.

Gamestonk Terminal 18.6k Jan 3, 2023
Shellcode runner to execute malicious payload and bypass AV

buffshark-shellcode-runner Python Shellcode Runner to execute malicious payload and bypass AV This script utilizes mmap(for linux) and win api wrapper

Momo Lenard 9 Dec 29, 2022
A simple python script to execute a command when a YubiKey is disconnected

YubiKeyExecute A python script to execute a command when a YubiKey / YubiKeys are disconnected. ‏‏‎ ‎ How to use: 1. Download the latest release and d

null 6 Mar 12, 2022
Automaton - python script to execute bash command based on changes in size of a file.

automaton python script to execute given command <= everytime size of a given file changes,hence everytime a file is modified.(almost) download automa

asrar bhat 1 Jan 3, 2022
Konsave lets use save your KDE Plasma customizatios and restore them very easily!

Konsave (Save Plasma Customization) A CLI program that will let you save and apply your KDE Plasma customizations with just one command! Als

null 439 Jan 2, 2023
TermPair lets developers securely share and control terminals in real time🔒

View and control terminals from your browser with end-to-end encryption ??

Chad Smith 1.5k Jan 5, 2023
CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that data.

CLabel is a terminal-based cluster labeling tool that allows you to explore text data interactively and label clusters based on reviewing that

Peter Baumgartner 29 Aug 9, 2022
The project help you to quickly build layouts in terminal,cross-platform

The project help you to quickly build layouts in terminal,cross-platform

gojuukaze 133 Nov 30, 2022
👻 Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal.

?? Ghoul is an easy to use information service, allowing you to get/add information on someone or something directly from your terminal. It c

Billy 11 Nov 10, 2021
Output Analyzer for you terminal commands

Output analyzer (OZER) You can specify a few words inside config.yaml file and specify the color you want to be used. installing: Install command usin

Ehsan Shirzadi 1 Oct 21, 2021
Fun project to generate The Matrix Code effect on you terminal.

Fun project to generate The Matrix Code effect on you terminal.

Henrique Bastos 11 Jul 13, 2022
A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands

PIGIT A terminal tool for git. When we use git, do you feel very uncomfortable with too long commands. For example: git status --short, this project c

Zachary 1 Apr 9, 2022
Todo - You could use terminal to set your todo

Python Tutorial You can learn how to build a terminal application(CLI applicatio

null 29 Jun 29, 2022
This is a CLI utility that allows you to view RedFlagDeals.com on the command line.

RFD Description Motivation Installation Usage View Hot Deals View and Sort Hot Deals Search Advanced View Posts Shell Completion bash zsh Description

Dave G 8 Nov 29, 2022
Jupyter notebook client in neovim

?? Jupyter-Nvim Read jupyter notebooks in neovim Note: The plugin is still in alpha stage ?? Usage Just open any *.ipynb file and voila! ✨ Contributin

Ahmed Khalf 85 Dec 29, 2022