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

pycharm + windows new line for every update #307

Open
chanansh opened this issue Nov 4, 2016 · 13 comments
Open

pycharm + windows new line for every update #307

chanansh opened this issue Nov 4, 2016 · 13 comments
Assignees
Labels
duplicate 🗐 Seen it before invalid ⛔ Not-an-issue or upstream (not-our-issue) question/docs ‽ Documentation clarification candidate to-review 🔍 Awaiting final confirmation

Comments

@chanansh
Copy link

chanansh commented Nov 4, 2016

I try the demo code:

from tqdm import trange
from time import sleep

for i in trange(10, desc='1st loop'):
    for j in trange(5, desc='2nd loop', leave=False):
        for k in trange(100, desc='3nd loop'):
            sleep(0.01)

and I get a new line per update rather than a carrier-return (see below sample)
What could be the reason?

1st loop:   0%|          | 0/10 [00:00<?, ?it/s]

2nd loop:   0%|          | 0/5 [00:00<?, ?it/s]


3nd loop:   0%|          | 0/100 [00:00<?, ?it/s]


3nd loop:  10%|█         | 10/100 [00:00<00:00, 92.96it/s]


3nd loop:  20%|██        | 20/100 [00:00<00:00, 93.60it/s]


3nd loop:  30%|███       | 30/100 [00:00<00:00, 94.18it/s]


3nd loop:  40%|████      | 40/100 [00:00<00:00, 94.64it/s]


@lrq3000
Copy link
Member

lrq3000 commented Nov 4, 2016

Sorry but PyCharm does not support progress bars (not just tqdm but any progress bar) because its console interpreter does not support line return \n nor cursor up characters. This has been reported several times but we cannot do anything about it... You should try to run your scripts inside your OS console or another terminal to get the progress bars, or use the tqdm_gui submodule (requires matplotlib but a native tk python version is on the way).

@piyusharma95
Copy link

Has the issue fixed yet?

@lwiklendt
Copy link

In PyCharm under the run/debug configuration enable "Emulate terminal in output console".
https://stackoverflow.com/questions/45012964/stdout-progress-bars-dont-work-in-pycharm

@casperdcl
Copy link
Sponsor Member

ah if people confirm that works we can add it to the FAQs.

@caiuspetronius
Copy link

It works. It can be changed via the following Menu path: Run -> Edit configurations -> Emulate terminal in output console (checkbox)

@casperdcl casperdcl self-assigned this Sep 22, 2019
@casperdcl casperdcl added question/docs ‽ Documentation clarification candidate to-review 🔍 Awaiting final confirmation labels Sep 22, 2019
@casperdcl casperdcl reopened this Sep 22, 2019
@casperdcl casperdcl added the invalid ⛔ Not-an-issue or upstream (not-our-issue) label Sep 22, 2019
@rtphokie
Copy link

rtphokie commented Oct 22, 2019

It works. It can be changed via the following Menu path: Run -> Edit configurations -> Emulate terminal in output console (checkbox)

I cant get it to work with TQDM or any other progress bar I try with Python 3.6 and PyCharmCE 2019.2.3 under Catalina. Neither "emulate terminal in output console" nor run in "python console" have any impact on progressbar output.

@UgoM
Copy link

UgoM commented Feb 5, 2020

It works. It can be changed via the following Menu path: Run -> Edit configurations -> Emulate terminal in output console (checkbox)

I cant get it to work with TQDM or any other progress bar I try with Python 3.6 and PyCharmCE 2019.2.3 under Catalina. Neither "emulate terminal in output console" nor run in "python console" have any impact on progressbar output.

Same here, python 3.8, Pycharm 2019.2.3-1 under arch.

@ConstantinB9
Copy link

For anyone still seeking a solution: try Emulate terminal in output console
under Configurations -> Edit Configuration -> Execution

This did solve some of my issues with the pycharm console
(Ubuntu, PyCharm Pro 2020.1.1 )

@twall
Copy link

twall commented Jun 1, 2020

There is no "Emulate terminal in output console" for remote (ssh) interpreters (which are only available in the pro version).

It is possible to edit ~/.ssh/rc to explicitly set the number of lines (PyCharm uses "vt100" as the terminal type):

if [ "$TERM" = "vt100" ]; then stty cols 160 >& /dev/null; fi

@odedbd
Copy link

odedbd commented Oct 20, 2020

Emulate terminal in output console does fix the progress bar for me (PyCharm 2020.2), but at the cost of not being able to use the interactive console when debugging. So that's a no go for my use case.

@jacksonthall22
Copy link

For anyone still struggling like I was, I just had an old print() hidden in my training loop...

@davidgilbertson
Copy link

@odedbd you can use the -i Python interpreter option to make the terminal session 'interactive' (you're left with a prompt when it's done).

In the run configuration:
image

So at least you can inspect variables after something runs:

image

But it's not great, I still prefer the PyCharm Python Console with auto-complete etc.

My personal fix is to check sys.stdout.isatty() and avoid multiple/complex tqdm use in environments that aren't TTYs (like PyCharm Python Console)

@odedbd
Copy link

odedbd commented Nov 14, 2022

@davidgilbertson thanksf or the suggestion. For now I simply dropped the tqdm progress bar I was using in favor of simpler logger messages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate 🗐 Seen it before invalid ⛔ Not-an-issue or upstream (not-our-issue) question/docs ‽ Documentation clarification candidate to-review 🔍 Awaiting final confirmation
Projects
None yet
Development

No branches or pull requests