Search code examples
pythonloadingtqdm

tqdm loading bar bug


the beginning of my loop looks like this -

for fname in tqdm(range(len(images)), position = 0, leave = True):

  0%|          | 0/26 [00:00<?, ?it/s]26 images found.
100%|██████████| 26/26 [00:13<00:00,  1.86it/s]

Any idea why this might be happening? (I need it to only print once)

I fixed it but I don't understand why it works. I have a print statement before my loop, if I remove it - it works fine, but it doesn't without it.


Solution

  • When you have a print statement inside your for loop it will print to your terminal and then display back the loading bar, so you will see multiple loading bar.