stdout progress bars don't work in Pycharm
Asked Answered
F

4

40

Many programs display progress bars by printing to stdout and then returning to beginning of line and printing again. This way they can achieve realtime progress bar appearence.

Unfortunately, in many cases this functionality does not work in PyCharm's console.

This is an example on how it shows keras train progress bar:

enter image description here

i.e. each progress bar change goes to separate line.

Is it possible to fix this?

Footworn answered 10/7, 2017 at 13:10 Comment(1)
Console is not a real terminal, you could try the "Emulate terminal in output console" option.Bartle
L
59

CrazyCoder's comment is the right way to go.

I just formalize his comment as an answer here.


Step1: Go to Run ---> Edit Configurations

enter image description here

Step2: Check the option: Emulate terminal in output console

enter image description here

Voilà

enter image description here

Leo answered 28/12, 2017 at 6:43 Comment(4)
But I can't run with Python console when I select this option, if I want check variables after run code, this way is not going to work...Underfur
for people using PyCharm Edu, which doesn't have the "Run" menu, you can access your Run configurations via Help --> Find Action --> Type "Edit Configurations" (source: jetbrains.com)Hild
This option is no longer present in 2020.1.Buddhology
Option is present in 2020.2Limelight
R
5

Emulate terminal in output console is gone from PyCharm 2022.2.1 (Professional Edition). Other suggestions?

enter image description here

Retiarius answered 28/10, 2022 at 14:8 Comment(0)
B
2

The only way I managed to get progress bars (I'm using tqdm 4.19.5 for a progress bar, PyCharm Community 2017.3.2 and Anaconda/Python 3.6.3) to work correctly was to uncheck the "Show command line afterwards" option:

enter image description here

enter image description here

enter image description here

The solution posted by Tay2510 (checking the "Emulate terminal in output console" option) didn't work for me.

One downside of my solution is that you lose console access after your script is done running.

Barbarism answered 5/1, 2018 at 18:9 Comment(1)
It looks like jetbrains took out the "Show command line afterwards" option. I don't see it anymore.Tipcat
A
0

For PyCharm 2024.1.3 (Community Edition) Build #PC-241.17890.14, built on June 4, 2024, it works as:

  1. Press 3dots button (right to Run button and Debug button)
  2. Edit...
  3. "Modify options, Alt+M"
  4. Check on "Emulate terminal in output console"

Works.

Avatar answered 12/7 at 8:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.