0

I have this problem that the IPython in jupyter notebook does not print the results interactively like command prompt or python regular shell. And by printing interactively I mean, it does not show the output at each step and for example, shows the output of a code block like this, at the end of the execution.

for i in raange(100):
    print(i)

I have never worked with jupyter notebook before, at least not locally, and when I did use it, it was on the GoogleColab. In GoogleColab there is no problem like what I said above.

So can anyone help me or at least tell me that have they experienced this problem too or is it just me who has this problem?

  • What is the problem with the linked solutions? It works for me (Python 3.7, IPython 7.12.0). What is the expected outcome of that code? – Péter Leéh Aug 08 '20 at 09:58
  • @PéterLeéh I linked that solution, just to say that I have tried that method and it did not work. I did not mean to say it was the solution for my problem, I just said that it is similar to my question. But now I have deleted it because it was making the question confusing. Please do look once more. The problem is that the printing buffer of IPython saves all of the output at runtime and shows it all together at the end of the execution. – Ali Khalili Aug 08 '20 at 16:08

1 Answers1

0

The solution shown in the question you linked works for me, just execute

from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"

in the first cell, and then it will output each line's output as follows:

a=5
a
a
a *2

>>> 5
>>> 5
>>> 10
johannesack
  • 660
  • 3
  • 19
  • I linked that solution, just to say that I have tried that method and it did not work. I did not mean to say it was the solution for my problem, I just said that it is similar to my question. But now I have deleted it because it was making the question confusing. Please do look once more. The problem is that the printing buffer of IPython saves all of the output at runtime and shows it all together at the end of the execution. – Ali Khalili Aug 08 '20 at 16:11