Log outputs are not shown in jupyter when calling another script

Viewed 77

I have a Jupyter notebook (.ipynb) with the following content:

%%bash

python log_test.py

which log_test.py is:

import time

print('this is first appearance...')

time.sleep(10)

print('after 10 sec sleep')

time.sleep(10)

print('after 10 sec sleep') 

When I execute the jupyter cell it doesn't show the output directly after print() function and waits until the job is completely done. I would like to know is it possible to do it in some way to show the output immediately (without waiting 20 sec)?

1 Answers

So I followed this website

therefore I replaced the code

%%bash
python log_test.py

with this line:

%run -i log_test.py

It printed out in real time.

Related