question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

A new line gets printed instead of updating the current line / Weird characters get printed

See original GitHub issue

Hi, Great library you’ve got. I started using it because I love the cool features

I just started working with alive-progress and tested it using the following script:

import time
items = range(10)                  # retrieve your set of items
with alive_bar(len(items)) as bar:   # declare your expected total
    for item in items:               # iterate as usual
        # process each item
        bar()                        # call after consuming one item
        time.sleep(1)

The output I get is : Screenshot 2020-12-05 165126

python prints the progress bar to a new line instead of updating the current line Also notice how some characters are like ? (question marks) inside boxes (I’m guessing something wrong with character encoding ??)

I’m using Python 3.8.3 on Windows 10 build 19041.630 The console I’m using is the windows command prompt The font used in the console is Consolas If you want more info, I’m willing to provide. Thank You !!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
rsalmeicommented, Jan 8, 2021

Yeah, it may be a limitation of the terminal itself. Please try on the new windows terminal: https://www.howtogeek.com/673729/heres-why-the-new-windows-10-terminal-is-amazing/

1reaction
rsalmeicommented, Dec 5, 2020

Hey man, thank you! I wish you like it even more after it start working right for you!

Well, it seems there’s two problems in there. The new line I’ve found recently it does occur on Windows, only inside the basic python interpreter. Unfortunately, all function calls inside python on Windows prints its result on screen!! Argh 😞 That’s why the lines all start with “on N: N”, it’s the current line that python interpreter arbitrarily prints…

So please try it inside ipython, it’s a way better environment anyway (I use it 100% of the time):

pip install ipython
ipython

The new version in the works (#51) will not return the current line, so it should fix that.

The other problem is the weird characters. Unfortunately I think the basic command prompt on Windows really does not support them. They are control chars that I use to improve presentation like clearing the line, hiding the cursor, etc. For this I recommend installing the new WSL - Windows Subsystem for Linux. I’ve installed it on my gaming machine with Windows 10 Home Edition, and it’s awesome! With it you get to use a very improved terminal app, with a much better shell like ZSH.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python - Print to the same line and not a new line?
hehe. Python Script: Print new line each time to shell rather than update existing line. I have a program that is telling me...
Read more >
Overwrite Previously Printed Lines | by Thijmen Dam
Print line, but end with a carriage return instead of a newline character. This moves the cursor back to the beginning of the...
Read more >
Advancing to the Next Print Line | Start Using C++
With C++, text sent to the screen does not automatically advance to the next physical line. You have to print a newline character...
Read more >
Python New Line: How to Print WITHOUT Newline in Python
To get the strings to print without a newline, in python2.x you will have to add a comma (,) at the end of...
Read more >
Your Guide to the Python print() Function
This prints an uppercase letter A and a newline character, which correspond to decimal values of 65 and 10 in ASCII. However, they're...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found