Amir
Amir

Reputation: 16587

Log outputs are not shown in jupyter when calling another script

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)?

Upvotes: 2

Views: 152

Answers (1)

Sebastian Baum
Sebastian Baum

Reputation: 365

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.

Upvotes: 1

Related Questions