Skip to content
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

pb.write and print don't work in jupyter notebook #644

Closed
KOLANICH opened this issue Nov 23, 2018 · 5 comments
Closed

pb.write and print don't work in jupyter notebook #644

KOLANICH opened this issue Nov 23, 2018 · 5 comments
Assignees
Labels
p2-bug-warning ⚠ Visual output bad to-fix ⌛ In progress

Comments

@KOLANICH
Copy link

KOLANICH commented Nov 23, 2018

The version used is 350640d
Neither

with tqdm(...) as pb:
    pb.write("test")

nor

with tqdm(...) as pb:
     print("test")

work.
It turned out that the text output is buffered somehow, and flushed only if there are lot of lines. It is not flushed even on cell execution finish.

@KOLANICH KOLANICH changed the title write doesn't work in jupyter notebook pb.write ant print doesn't work in jupyter notebook Nov 23, 2018
@KOLANICH KOLANICH changed the title pb.write ant print doesn't work in jupyter notebook pb.write ant print don't work in jupyter notebook Nov 23, 2018
@KOLANICH KOLANICH changed the title pb.write ant print don't work in jupyter notebook pb.write and print don't work in jupyter notebook Nov 23, 2018
@casperdcl
Copy link
Sponsor Member

that's odd. if that's jupyter's decision then I'm not sure if we should try to forcefully flush...

@KOLANICH
Copy link
Author

that's jupyter's decision then I'm not sure if we should try to forcefully flush...

I have tried, it doesn't work.

@chengs chengs self-assigned this Nov 27, 2018
@chengs
Copy link
Contributor

chengs commented Nov 27, 2018

let me have a look.

This is because tqdm.write writes to stdout by default. And Jupyter notebook handles stdout not as same as console does. Actually, in Jupyter, tqdm_notebook.write should directly write to IPython.output. And the logic in tqdm.write does not fit Jupyter, because we don't need to clear the previous bars before writing something.

So, @casperdcl a new tqdm_notebook.write function is required to fix this issue. However, I won't have time recently. So a PR from someone else is very welcomed. If not, I will find a slot to fix it in the end of December or begining of Jan.

@chengs chengs added to-fix ⌛ In progress p2-bug-warning ⚠ Visual output bad labels Dec 2, 2018
@KOLANICH
Copy link
Author

KOLANICH commented Dec 2, 2018

BTW, in jupyterlab without widgets module installed the output works. I have not tested with widgets installed, because in jupyterlab widgets are npm module, not python one.

P.S. jupyterlab is badly designed, so I prefer to stay on jupyter notebook.

@chengs
Copy link
Contributor

chengs commented Nov 16, 2021

Closed as the problem is fixed.

@chengs chengs closed this as completed Nov 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p2-bug-warning ⚠ Visual output bad to-fix ⌛ In progress
Projects
None yet
Development

No branches or pull requests

3 participants