How to copy from a Jupyter notebook cell?

I want to copy text from a Jupyter notebook cell to some other application, for example a text editor. I can copy the output of a cell, but not the content of a cell. Is there a way to do it (without downloading the notebook as a Julia file)?

I’m using Firefox and Jupyter 6.3.0 on Ubuntu.

Can you, within your cell, press Ctrl+A together and then Ctrl+C to copy? I am a bit unclear what you are trying to do. Could you explain further?


That’s exactly what I tried!

Now I’ve figured out that the problem is the difference between “primary selection” and “clipboard” under X11. Jupyter copies to the clipboard, but pressing the middle mouse button inserts the primary selection in the text editor. You can get the clipboard with some key combination.

Anyway, thanks!

1 Like

Ah gotcha – what text editor are you using? If you are using (neo)vim, have you seen the fantastic jupytext extension? It allows you to use notebooks within the vim text editor. Highly recommend as I use it all the time. Also, plays nice with linux!

1 Like

I’m using terminal-based editors like jed or nano. The mouse buttons are handled by the terminal emulator (urxvt).

jupytext.vim is very interesting, but it seems to be for editing the notebook only, not for interactive use.

Oh yea – it’s for interactive use as well. Maybe it’s not clear from the documentation, but what you can do is open the Jupyter notebook within a browser (with your kernel) and also open the notebook within your editor. Then, when you change the notebook in your editor, if you save, it should automatically update the notebook contents within the browser as well so you can run scripts in an attached kernel.

Cool. I use Neovim with konsole or alacritty.

You can export your notebook from the File menu selecting “Save and export notebook as” then select “asciidoc” and there you have all your input and output as txt file.
Usually the downloaded file can be found in your “Downloads” directory.