Both on Debian and Ubuntu, tqdm.write() is not working as expected.
Messages are written but the progress bar behaves as if I would be using print. This used to work correctly with a previous version of tqdm (4.19.4) but after installing a new server and using version 4.31.1 it now behaves like this:
-- sir.uylp -> no data for requested time window
-- sir.uyni -> no data for requested time window
-- sir.uypt -> no data for requested time window
-- sir.uyri -> no data for requested time window
99%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 1120/1127 [01:16<00:00, 20.45it/s] -- sir.uyrv -> no data for requested time window
-- sir.uysj -> no data for requested time window
-- sir.uyta -> no data for requested time window
-- sir.valp -> no data for requested time window
100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 1124/1127 [01:16<00:00, 22.86it/s] -- sir.varg -> no data for requested time window
-- sir.vesl -> adding...
-- sir.vico -> no data for requested time window
100%|โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ| 1127/1127 [01:18<00:00, 14.41it/s]
Note that the text starts at the end of the progress bar. I've searched the issues page but could not find anything similar. Not sure if it is relevant, but I'm running the program over ssh. Again, this work fine with the previous version I had. The code is very simple:
`for Stn in tqdm(sorted(stations), ncols=80):
NetworkCode = Stn['NetworkCode']
StationCode = Stn['StationCode']
rs = cnn.query(
'SELECT * FROM rinex_proc WHERE "NetworkCode" = \'%s\' AND "StationCode" = \'%s\' AND '
'"ObservationSTime" >= \'%s\' AND "ObservationETime" <= \'%s\''
% (NetworkCode, StationCode, (dates[0] - 1).first_epoch(), (dates[1] + 1).last_epoch()))
if rs.ntuples() > 0:
tqdm.write(' -- %s.%s -> adding...' % (NetworkCode, StationCode))
try:
stn_obj.append(Station(cnn, NetworkCode, StationCode, dates))
except pyETMException:
tqdm.write(' %s.%s -> station exists, but there was a problem initializing ETM.'
% (NetworkCode, StationCode))
else:
tqdm.write(' -- %s.%s -> no data for requested time window' % (NetworkCode, StationCode))`
is this code running in django or similar? And does downgrading just tqdm to 4.19.4 fix it?
No, I'm not using django. I can confirm that after removing version 4.31.1 and installing 4.19.4 the problem is gone.
I can confirm a similar issue with tqdm.write on Ubuntu 18.04 and tqdm==4.31.1 duplicating the progress bar. It appears to be time dependent in python2 and not python3:
from tqdm import tqdm
for i in tqdm(range(5)):
tqdm.write('Here: {}'.format(i))
python2.7 0%| | 0/5 [00:00<?, ?it/s]Here: 0
Here: 1
Here: 2
Here: 3
Here: 4
100%|โโโโโโโโโโ| 5/5 [00:00<00:00, 4725.44it/s]
python3.6 :+1:Here: 0
Here: 1
Here: 2
Here: 3
Here: 4
100%|โโโโโโโโโโโโโโโโ| 5/5 [00:00<00:00, 17303.23it/s]
import time
from tqdm import tqdm
for i in tqdm(range(5)):
tqdm.write('Here: {}'.format(i))
time.sleep(1)
python2.7 0%| | 0/5 [00:00<?, ?it/s]Here: 0
20%|โโ | 1/5 [00:01<00:04, 1.00s/it]Here: 1
40%|โโโโ | 2/5 [00:02<00:03, 1.00s/it]Here: 2
60%|โโโโโโ | 3/5 [00:03<00:02, 1.00s/it]Here: 3
80%|โโโโโโโโ | 4/5 [00:04<00:01, 1.00s/it]Here: 4
100%|โโโโโโโโโโ| 5/5 [00:05<00:00, 1.00s/it]
python3.6 :+1:Here: 0
Here: 1
Here: 2
Here: 3
Here: 4
100%|โโโโโโโโโโโโโโโโโโโ| 5/5 [00:05<00:00, 1.00s/it]
Downgrading to tqdm==4.30.0 fixes this ...
Both samples from @jccurtis seem to work for me on 4.50.2-git.UNKNOWN (built from master) on Python 2.7.18. Could you or somewhen else confirm or deny this?
Most helpful comment
I can confirm a similar issue with
tqdm.writeon Ubuntu 18.04 andtqdm==4.31.1duplicating the progress bar. It appears to be time dependent in python2 and not python3:simple loop with no sleep
python2.7python3.6:+1:1 sec sleep
python2.7python3.6:+1:Downgrading to
tqdm==4.30.0fixes this ...