Using a progress bar to monitor computation progress in the notebook (e.g. tqdm) runs into a visual updating glitch when run following the kernel being interrupted (either by keyboard or a break statement). Any progress bar run after the interruption results in output like the following:
Only a restart of the kernel restores behavior.
Running notebook 4.4.1 on macOS 10.12.3 and Safari (Python 3.6).
Have you got a convenient notebook to reproduce this?
@takluyver @fonnesbeck Same issue here as well! The only solution I stumbled over so far is to restart the kernel. Also, if you interrupt multiple times, it accumulates lines between every update. For example, two interrupts would accumulate two lines. Look at the following:

Sorry, just noticed the request for an example. I will post something momentarily.
I run the following code:

If you create a conda env with pymc3:
conda create -n test pymc3 notebook
and try running one of the example notebooks, for example this one, the behavior can be replicated by interrupting the call to sample down at line 9.
Any ideas on this one? It continues to be an issue in current master.
@fonnesbeck I think we could just use the tqdm jupyter version?
The bug affects me as well: if I interrupt in the middle of the tqdm bar, I must restart the kernel to avoid this issue.
This is tedious because it is very common to interrupt long processes (you hit ctrl-enter, and check for bugs or improvements while the job is running, if any found, you interrupt, fix and re-run).
For those of you using tqdm, use tqdm_notebook instead.
See: https://github.com/tqdm/tqdm/issues/375#issuecomment-328466265
It works if you go on of the ways:
pbar = tqdm(range(10))
try:
for i in pbar:
sleep(1)
if i==5:
raise NotImplementedError()
finally:
pbar.close()
or
with tqdm(range(10)) as pbar:
for i in pbar:
sleep(1)
if i==5:
raise NotImplementedError()
It works if you go on of the ways:
pbar = tqdm(range(10)) try: for i in pbar: sleep(1) if i==5: raise NotImplementedError() finally: pbar.close()or
with tqdm(range(10)) as pbar: for i in pbar: sleep(1) if i==5: raise NotImplementedError()
Didn't work for me.
So this is still unsolved? any way to make it behave normally without restarting the kernels?
Going through this issue as well. If anyone has a solution please let me know.
None of the above works for me. I find that running to following sorts this issue after error (It just clears all the instances of progress bars in the background):
from tqdm import tqdm
# blah blah your code errored
tqdm._instances.clear()
(If you would like to updoot - I've posted this solution on stack)
None of the above works for me. I find that running to following sorts this issue after error (It just clears all the instances of progress bars in the background):
from tqdm import tqdm # blah blah your code errored tqdm._instances.clear()(If you would like to updoot - I've posted this solution on stack)
Didn't work for me(.
None of the above works for me. I find that running to following sorts this issue after error (It just clears all the instances of progress bars in the background):
from tqdm import tqdm # blah blah your code errored tqdm._instances.clear()(If you would like to updoot - I've posted this solution on stack)
Didn't work for me(.
Oh dear. Do you want to post the output of tqdm._instances?
tqdm>=4.45.0 should not require any special handling on exceptions (no need to catch and clear instances). If it does, please post on https://github.com/tqdm/tqdm/issues/548
Most helpful comment
None of the above works for me. I find that running to following sorts this issue after error (It just clears all the instances of progress bars in the background):
(If you would like to updoot - I've posted this solution on stack)