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
Add support for Spyder in tqdm.auto #1559
base: master
Are you sure you want to change the base?
Conversation
tqdm/autonotebook.py
Outdated
@@ -21,7 +22,11 @@ | |||
except Exception: | |||
from .std import tqdm, trange | |||
else: # pragma: no cover | |||
from .notebook import tqdm, trange | |||
if "SPY_TESTING" in os.environ: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- is
SPY_TESTING
always defined inside a spyder environment? - is it fairly plausible for
SPY_TESTING
to be defined outside spyder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have used this approach for many years without any issues. Checking environment variables of the form SPY_XXXX
is also suggested in https://stackoverflow.com/questions/53829284/how-to-know-if-a-script-is-running-in-spyder-or-any-other-python-ide.
I will create an issue at the Spyder issue tracker to check this is a good approach.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@casperdcl I have updated the detection method based on the suggestion by the Spyder devs. See spyder-ide/spyder#21929
The Spyder environment console uses IPython, and are therefore recognized by tqdm as notebooks. The progress bar does only work with
tqmd.std
though. In this PR we detect Spyder and import the correct packages.The reason for making the change here is that with third-party packages we cannot always control whether
tqdm
is imported fromauto
,autonotebook
orstd
.An alternative would be to check in
tqdm.autonotebook
for a special environment variable that overrides the automatic detection.