tqdm icon indicating copy to clipboard operation
tqdm copied to clipboard

progress bar moves upwards in screen

Open saj1919 opened this issue 6 years ago • 11 comments

When I run for loop with tqdm in terminal ... it works fine. When I run the same thing in linux screen ... below thing happens. I think its a bug. Any code with tqdm around for loop can be checked for the replication. Was able to replicate in Ubuntu and Mac

Steps :

  1. screen -Rd test_screen
  2. run python script with tqdm for loop Thats it.
Screenshot 2019-08-22 at 5 44 17 PM

saj1919 avatar Aug 22 '19 12:08 saj1919

duplicate of #336?

Looks like you could fix it with ncols=150 or similar, screen seems to be reporting too many ncols.

casperdcl avatar Aug 23 '19 02:08 casperdcl

It is not a direct duplicate of #336 as here progress-bar is moving upwards which is worse. In case you press Enter it comes down as usual and then again keeps going upwards. Hard to keep track of whats running because normal print statements will print as usual over these progress-bar once tqdm is finished.

I tried ncols=150 ... didn't work.

saj1919 avatar Aug 23 '19 05:08 saj1919

so with ncols=150, the bar doesn't fill the full width of the screen but you still see it moving upwards?

casperdcl avatar Aug 23 '19 13:08 casperdcl

No different output even after choosing ncols=150 ... it moved upwards still.

saj1919 avatar Aug 28 '19 10:08 saj1919

right. judging by the fact that it works fine in your terminal outside screen, though, I'm hoping it's a bug with screen.

There's no way a single bar should be moving upwards. Nested ones; perhaps.

Can you try:

print('a\nb\rc\nd\re')

the output should be

a
c
e

casperdcl avatar Aug 28 '19 14:08 casperdcl

Hi, sorry for delayed answer. Output ->

a
c
e

Were you able to reproduce this issue on Ubuntu screens ? For me it happens every time. And my use case is to run my code in screen and see the progress. Now I am using nohup instead of screen just to see the progress.

saj1919 avatar Sep 06 '19 06:09 saj1919

  • I use tmux which seems to work without issue
  • you may need screen -U (https://stackoverflow.com/questions/52250556/tqdm-in-screen-environment-printing-new-line-and-unknown-charactors)

casperdcl avatar Sep 28 '19 16:09 casperdcl

When calling tqdm, try to include argument ascii=True in order to deal with screen not being UTF-8 friendly. Something like below:

for item in tqdm(items, total=len(items), ascii=True):
        pass

mostafajahanifar avatar Aug 04 '21 15:08 mostafajahanifar

based on this post you need to enable UTF-8 encoding. To do that simply run screen -U , assuming you are using the screen multiplexer It worked for me at least 😃

stogiannidis avatar Mar 05 '23 21:03 stogiannidis

I have same problem with windows wsl,And I found,If change shell width large. it is not move.if width small.it is move. because can see two rows info on screen. if change ncols do not work. is it any other function to slove it? @casperdcl @stoyian i found tqdm(desc=self.name,position = self.position) position is important with this problem. if tqdm suport position list. can reslove it. position = [0,1,2] like this or autoposition

xiezhipeng-git avatar Mar 30 '23 13:03 xiezhipeng-git

duplicate of #336?

Looks like you could fix it with ncols=150 or similar, screen seems to be reporting too many ncols.

This works for me. I set ncols=100 and it works fine.

FuryMartin avatar Sep 19 '24 12:09 FuryMartin