Skip to content

Instantly share code, notes, and snippets.

@jaymody
Created May 27, 2020 17:54
Show Gist options
  • Save jaymody/8252f91b490c2a0612be7dce3d8eb921 to your computer and use it in GitHub Desktop.
Save jaymody/8252f91b490c2a0612be7dce3d8eb921 to your computer and use it in GitHub Desktop.
Resetting/fixing multiline tqdm output without having to restart a jupyter notebook.
# source - https://stackoverflow.com/a/61230293/11070463
#
# Often, i'll be working in on a jupyter notebook and an error/bug will
# interrupt the execution of something that was wrapped with the tqdm
# function. This has the annoying side effect where your next tqdm call
# will be multilined. To fix this, you can the below two lines of code
# and it'll be fixed! (if tqdm gets interrupted again, you'll have the
# run these two lines again).
while len(tqdm._instances) > 0:
tqdm._instances.pop().close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment