Skip to content

Realtime output from a shell command in Jupyter notebook #4048

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bfurtwa opened this issue Sep 28, 2018 · 7 comments
Closed

Realtime output from a shell command in Jupyter notebook #4048

bfurtwa opened this issue Sep 28, 2018 · 7 comments

Comments

@bfurtwa
Copy link

bfurtwa commented Sep 28, 2018

I'm telling jupyter to execute a python script:

!python build_database.py

When executed from the terminal, the python script prints the progress during execution. However, in the jupyter notebook, I get all output printed as a list of strings, AFTER the execution. Is there a way to see the output live?

@amrs-tech
Copy link

@Benni93 Can you please provide any screenshots for your both cases ?

@bfurtwa
Copy link
Author

bfurtwa commented Sep 29, 2018

This is from the jupyter notebook. It is not live, the output is shown after everything is finished.

unbenannt

This is from the shell script. The output is live, I see every iteration.

unbenannt

@amrs-tech
Copy link

Have you tried running in the notebook as follows ?
%run build_database.py

@bfurtwa
Copy link
Author

bfurtwa commented Sep 30, 2018

Yes, but I can´t run the script in the jupyter notebook, since it uses asyncio. (#3397)

@amrs-tech
Copy link

I too a newcomer as a contributor. I'll try to help you. I'll check for any solution to your problem. But I think I might take some time.

@bollwyvl
Copy link
Contributor

bollwyvl commented Sep 30, 2018 via email

@krassowski
Copy link
Member

Closing as this is a solved problem with IPython 8.32:

print-loop-sleep.webm

If that does not work for you it might be because of Python buffering see https://docs.python.org/3/using/cmdline.html#envvar-PYTHONUNBUFFERED.

In future such issues would be best opened on repository of respective kernels or underlying implementations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants