Austin
Austin

Reputation: 7319

Intermediate bash output in Jupyter notebook

When I run this in terminal:

cd 1st_flask_app_1/
python3 app.py

I get the output:

 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)

When I try to run the same command in a Jupyter notebook with the cell magic %%bash, I get no printed output, but the web app still starts up and I can visit it. If I then stop the cell I get the output:

Process is interrupted.

So it looks like the Jupyter notebook with %%bash cell magic is printing final command outputs, but not intermediate outputs. Is there any way to also print the intermediate outputs?

Upvotes: 3

Views: 936

Answers (1)

Allan
Allan

Reputation: 12438

For some reason it looks like your stdout/stderr are not properly attached to your bash...

Could you try to redirect your command stdout and stderr to a log file in append mode?

python3 app.py >> application.log 2>&1

or you could also pipe it with tee

python3 app.py 2>&1 | tee -a application.log

I hope this helps you!

Upvotes: 1

Related Questions