There is nothing wrong with your code. Running in plain Ubuntu 18 / Python3 it behaves as expected.
I guess this is some kind of buffering issue (or a bug in Jupyter).
Based on the link @unutbu posted, it seems that only a minor time delay is needed to allow Jupyter to get its ship in shape.
import time
for i in range(100000):
print(i, end='\r')
time.sleep(0) # EDIT, somehow even this works too.
print("")
Obviously if you really do have a huge amount of output (like 100k lines), this is far from ideal. But the real delay is in the flushing and re-painting of the screen, not the actual time.sleep()
.
If you are doing this sort of thing in a quick-repetition loop, it may be better to only update the progress-bar once every few seconds (or so). This can be accomplished by checking for a time delta.