fastai / fastprogress

Simple and flexible progress bar for Jupyter Notebook and console
Apache License 2.0
1.08k stars 105 forks source link

fix detection of PyCharm console as TTY #89

Closed johan12345 closed 2 years ago

johan12345 commented 3 years ago

When running fastprogress in PyCharm (both as part of a script as well as in the interactive Python console), fastprogress does not output a progress bar: image (same behavior as e.g. in #62)

This is because sys.stdout.isatty() returns False within PyCharm, and therefore the check in printing fails: https://github.com/fastai/fastprogress/blob/67d40725e0225de51c0dc43255fd78681c014eb8/fastprogress/fastprogress.py#L214

This PR adds an additional check for the PYCHARM_HOSTED environment variable to find out when fastprogress is run within PyCharm.

An alternative would be to set the "Emulate terminal in output console" option in PyCharm, however this only seems to apply to run configurations, not to the interactive Python console.

jph00 commented 2 years ago

This is an nbdev project, so edits need to be done directly in the notebooks. I've fixed that in master now.