'Is there a way to reopen a running JupyterLab tab with a output stream?
If I run
import time
for i in range(999):
print (i)
time.sleep(1)
close the tab and reopen, it wont show the live output stream. I checked, its running in the background.
is there a way to come back to a running script after I closed the tab?
video demo: https://imgur.com/hRSxEdh
Solution 1:[1]
First thing first: code doesn't stop on tab closing (and you can see it from the log if you are launching JN from Anaconda Prompt). This is a good hint to find a viable solution.
Actually there are many ways to do this, and I'll suggest to dig this very good answer for a lot of other methods.
To me the most Jupyter Notebook-ish solution is to use the cell magic %%capture.
How to use it:
%%capture temp_output
# your running script here
Save the Notebook, close the tab, do whatever you want. Go back to the notebook, open it and:
temp_output.show()
Will let have your result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Carlo |
