I am trying to copy cells from one jupyter notebook to another. How this is possible?
7 Answers
This feature has been introduced in Jupyter Notebook 5.0.
Use pip install notebook --upgrade
to upgrade to the latest release.
The old shortcuts C
, V
and X
work only for copying and pasting inside one notebook. In order to do it across tabs, you should use Ctrl-C
and Ctrl-V
(Cmd-C
and Cmd-V
on Mac).
Note on multiple cells: currently (jupyter 6.0.0) on Mac+chrome using shift-click to select the cells then cmd-C does NOT work, while using the keyboard with shift-down-arrow does! (thanks drevicko for pointing this out)
-
2
pip install notebook --upgrade
worked for me only up to version 4.3, butpip install notebook==5.1.0rc2
did it's thing– PafnucyAug 24, 2017 at 8:40 -
3Your method only works for me to copy and paste markup cells across jupyter notebooks. When I do
Ctrl - C
on code cells, it just sends me to Edit Mode. What did I do wrong here? Thanks. Jan 18, 2019 at 15:13 -
2
-
-
1Ctrl - C / Ctrl - V work, but it takes about half minutes for the pasted content to show up in the new notebook, with Jupyter 6.0 on Ubuntu 18.04– Yu ShenOct 16, 2019 at 14:38
With jupyter 5.0.0, copy paste of one or many cells from one notebook to another works with Cmd C Cmd V (Mac).
For copying many cells together, select the first one then the last one with shift arrow (up or down).
The tool bar does not work for this purpose.
-
6Ctrl-C/Ctrl-V on linux. And when you paste make sure you're in Command mode (Blue line on the left of the cell), otherwise it'll collapse all copied cells into one if you're in Edit mode (Green line). Hit Esc to switch between modes.– stasonAug 9, 2018 at 2:26
-
3NOTE: currently (jupyter 6.0.0) on Mac+chrome using shift-click to select the cells then cmd-C does NOT work!! Using shift-down-arrow however does (odd behaviour, but there you are!). Visually, shift-click and shift-down-arrow seem identical, but apparently not...– drevickoAug 27, 2019 at 3:55
I have not done it myself though, but general practice is to avoid doing it as it can disturb the Cell JSON. It was not even possible until a few versions before. Recent Github posts has made it possible to do so though. Copy paste the cell in question to a code editor such as Atom or Sublime Text, make the changes you want to do and then paste it into the new Jupyter notebook. It should work.
-
I understand your recommendation, but anyway I would like to know how this is possible Oct 28, 2016 at 16:43
-
This request has been closed in Github, so it pretty much means it has been resolved. You can try this link and see if you can code up something like this: Oct 28, 2016 at 17:29
-
2I have already read it before asking. They are saying that the problem is solved without telling how. Oct 28, 2016 at 17:43
For windows-
Use Ctrl + Shift + C
to copy cells after selecting them using shift + arrow
keys.
Then, switch to the notebook to which you want to copy the selected cells and go to command mode in it by pressing Esc
key.
Then, use Ctrl + Shift + V
to paste the cells in that notebook.
Note- I have not tested this on Linux but should work just as the procedure above.
VSCode can open and execute jupyter notebooks.
In the same software it is also possible to cut/copy and paste from one notebook to another (something that I didn't manage to do with jupyter notebook
or lab
).
It saved me a lot of time.
-
note that, as pointed out in other answers, this capability was added also in jupyter and jupyterlab. Sep 26 at 10:33
In JupyterLab, you can view two notebooks arranged as panes side-by-side. (Or even two views of the same notebook.)
Then you can select a cell or continuous range of them. When they are highlighted go to the top cell and click and drag over to the other notebook to copy them.
You can download the cell content as .py file from jupier and then you can copy and paste wherever you want