Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong output in Windows console #454

Closed
vuki opened this issue Oct 1, 2017 · 24 comments · Fixed by #1180
Closed

Wrong output in Windows console #454

vuki opened this issue Oct 1, 2017 · 24 comments · Fixed by #1180
Assignees
Labels
to-review 🔍 Awaiting final confirmation

Comments

@vuki
Copy link

vuki commented Oct 1, 2017

Standard Windows 10 console (cmd.exe). Python 3.6.2. Test code:

import tqdm
import time

for i in tqdm.trange(10):
    time.sleep(0.1)

Output:
clipboard01

Is this expected? I'm sure it worked correctly in some older version.

@casperdcl
Copy link
Sponsor Member

which version of tqdm are you using?

@vuki
Copy link
Author

vuki commented Oct 2, 2017

tqdm==4.18.0

Edit: I use a high dpi display with 150% scaling, if that matters.

Edit 2: when I set the font size to 14, it works correctly. But I need to set the font size to 16 (because of the high dpi), and with this font, the effect is as I shown above.

@casperdcl
Copy link
Sponsor Member

casperdcl commented Oct 4, 2017

interesting. so windows is incorrectly reporting the terminal width when you mess with fonts and scaling. you could always use trange(..., ncols=75) or whatever to fix the width

@vuki
Copy link
Author

vuki commented Oct 4, 2017

Setting ncols does not help. The progress bar is shorter but the text still wraps if the number of iterations is sufficiently large. Interestingly, I see the cursor positioned beyond the line (see screenshot) and it moves further with each iteration, eventually skipping to a new line.
image

Progress bar works fine with ascii=True. There is obviously an error with unicode characters in Windows console.

@casperdcl
Copy link
Sponsor Member

casperdcl commented Oct 5, 2017

yes looks like it. I just tried win10 + py27, and couldn't get unicode working at all. it could be that windows thinks the unicode characters are "widechars"

@vuki
Copy link
Author

vuki commented Oct 5, 2017

Unicode support for Windows console was added in python 3.6. So it should work for me. Maybe the number of characters going backwards when updating the bar is calculated incorrectly? It's strange that the result depends on the font size. BTW, I believe that Unicode characters are widechars.

@casperdcl
Copy link
Sponsor Member

well, the true widths of many unicode chars are not wide, which some environments don't seem to understand

@IceflowRE
Copy link

IceflowRE commented Oct 10, 2017

I cant confirm the experience above inside the windows comand line. But i have this problems when i use the PyCharm console.


With mutlithreading support, like i already mentioned in #329.

I get this output with unicode:

D:\Iceflower\programming\tqdm>python test.py
#0, est. 2.50s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:05<00:00, 840.30it/s]
#1, est. 1.70s:  99%|███████████████████████████████████████████████████████████? | 4936/5000 [00:05<00:00, 838.44it/s]
#1, est. 1.70s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:05<00:00, 838.20it/s]
#2, est. 1.20s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:05<00:00, 836.62it/s]
#3, est. 1.00s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 833.22it/s]
#4, est. 0.83s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 823.69it/s]
#5, est. 0.71s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 830.42it/s]
#6, est. 0.62s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 821.60it/s]
#7, est. 0.56s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 816.37it/s]
#8, est. 0.50s: 100%|█████████████████████████████████████████████████████████████| 5000/5000 [00:06<00:00, 823.41it/s]
D:\Iceflower\programming\tqdm>

and this with ascii=True

D:\Iceflower\programming\tqdm>python test.py
#0, est. 2.50s: 100%|###########################################| 5000/5000 [00:05<00:00, 853.46it/s]
#1, est. 1.70s:  98%|##########################################2| 4917/5000 [00:05<00:00, 847.49it/s]
#1, est. 1.70s: 100%|###########################################| 5000/5000 [00:05<00:00, 848.74it/s]
#2, est. 1.20s: 100%|###########################################| 5000/5000 [00:05<00:00, 849.17it/s]
#3, est. 1.00s: 100%|###########################################| 5000/5000 [00:05<00:00, 844.14it/s]
#4, est. 0.83s: 100%|###########################################| 5000/5000 [00:05<00:00, 844.86it/s]
#5, est. 0.71s: 100%|###########################################| 5000/5000 [00:05<00:00, 841.36it/s]
#6, est. 0.62s: 100%|###########################################| 5000/5000 [00:05<00:00, 842.14it/s]
#7, est. 0.56s: 100%|###########################################| 5000/5000 [00:05<00:00, 842.64it/s]
#8, est. 0.50s: 100%|###########################################| 5000/5000 [00:05<00:00, 839.17it/s]
D:\Iceflower\programming\tqdm>

@Raymondlx
Copy link

Hey guys, thanks for your answers.
I tried with setting ascii = True, then it works well on my windows.

@gmonkman
Copy link

On windows 10 development in PTVS, python dos console output looks as follows with simple range. Notice the odd \uXXXX chars at the end. This also causes status on each newline unless ncols reduced:

for x in tqdm(range(10000)):
        sleep(0.001)

capture

@casperdcl
Copy link
Sponsor Member

That's partial unicode support. You can probably fix it with tqdm(..., ascii=True)

@casperdcl
Copy link
Sponsor Member

@IceflowRE your PyCharm issue is mentioned in https://github.com/tqdm/tqdm#faq-and-known-issues

@casperdcl
Copy link
Sponsor Member

Might add to the FAQs that environments which lie about unicode support will also have problems without ascii=True

@gmonkman
Copy link

gmonkman commented Mar 30, 2018

ta, yup, tried ascii=True after following an earlier comment thread and it did the trick.

@casperdcl casperdcl self-assigned this Mar 31, 2018
@casperdcl casperdcl added the to-review 🔍 Awaiting final confirmation label Mar 31, 2018
casperdcl added a commit that referenced this issue Apr 3, 2018
- closes #454
- TODO: might want to autodetect semi-unicode support and fallback to ascii?
@qizhuli
Copy link

qizhuli commented Sep 12, 2019

I added ascii=True to the call, but still get the issue.

Environment:

Using git-bash on Windows 10 to connect to an Ubuntu server. Code is run on the Ubuntu server, and the output is viewed from the git-bash console on Windows 10.

@Feynt
Copy link

Feynt commented Nov 26, 2019

I can confirm this issue occurs on a Raspberry Pi when using the defaults. Usually the bar flows as normal, but occasionally on both Windows (terminal emulator for zsh/ubuntu image) and Raspbian Buster it will show a standard replacement character (�) and skip a line. The character may show up in a random location along the progress bar, not at the end.

ascii=True resolves the issue, but I kind of dig the smooth bar when it works. Oddly it works most of the time, it's only once in a while that it happens. Particularly for tracking the download of a larger file. Terminal font shows as Monospace Regular according to LXTerminal in Raspbian Buster, and DejaVu Sans Mono for Powerline in mintty 3.0.0 running terminal emulation for WSL on Win10.

@Garve
Copy link

Garve commented Nov 27, 2019

Still persists on Windows 10 terminal for me, also with ascii=True. Python 3.8.0, tqdm version 4.39.0.

@bobshih
Copy link

bobshih commented Sep 4, 2020

Hi,
Currently, I use tqdm in PuTTy in windows 10.
But the putty is connected to a linux server.
The output progress bar is broken.
There are many new lines, like the image below.
Does any have idea to solve it?
Thanks in advance.
image

below is the locale setting.
image

The version of tqdm I used is 4.48.2

@RawFisher
Copy link

Hi,
Currently, I use tqdm in PuTTy in windows 10.
But the putty is connected to a linux server.
The output progress bar is broken.
There are many new lines, like the image below.
Does any have idea to solve it?
Thanks in advance.
image

below is the locale setting.
image

The version of tqdm I used is 4.48.2

image
Do not tick this option
It works for me

@MacwinWin
Copy link

'ascii=True' still not work for me. But though the code below, the symptoms can be relieved a little.

import time
from tqdm import tqdm

with tqdm(total=3, desc='level_1', position=0, leave=False) as pbar:
    for i in tqdm(range(3)):
        for j in tqdm(range(5), desc='level_2', position=0, leave=True):
            time.sleep(0.1)
        pbar.update()

3

@casperdcl
Copy link
Sponsor Member

@MacwinWin sounds like you're missing colorama #1139 which should become automatic next release #1180

@MacwinWin
Copy link

@casperdcl Thanks a lot.
1

@LikeToAccess
Copy link

image
image

# this is my tqdm function
for row in tqdm(file, total=file_line_count(file_path)):

There is still a small question mark/empty rectangle symbol appearing for me in the Windows Command Prompt and Windows Powershell.

This is running on Windows Server 2022 Datacenter 21H2 using Python 3.10.2 and tqdm-4.62.3.

@1454147447
Copy link

Everytime I restart Terminal multiplexing like tmux or screen,many lines of tqdm will appear on the screen
QQ图片20221006134224

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to-review 🔍 Awaiting final confirmation
Projects
None yet
Development

Successfully merging a pull request may close this issue.