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

How to detect python is running inside Spyder #21929

Closed
eendebakpt opened this issue Mar 25, 2024 · 2 comments
Closed

How to detect python is running inside Spyder #21929

eendebakpt opened this issue Mar 25, 2024 · 2 comments

Comments

@eendebakpt
Copy link
Contributor

Problem Description

Is the an "official" way to detect a python session is running as a console inside Spyder?

There are some methods listed in https://stackoverflow.com/questions/53829284/how-to-know-if-a-script-is-running-in-spyder-or-any-other-python-ide, but it is not directly clear whether there is a preferred one.

Also see tqdm/tqdm#1559

@ccordoba12
Copy link
Member

ccordoba12 commented Apr 3, 2024

Hey @eendebakpt, thanks for reporting. Between the two methods mentioned in the SO question you referenced, I think it's safer to use the second one, i.e.

from IPython import get_ipython

shell_cls_name = get_ipython().__class__.__name__
if shell_cls_name == 'SpyderShell':
    # Do things only for Spyder
    ...

That's because we're considering to remove all env vars we use to start a kernel (the SPY_* ones mentioned there), but SpyderShell is not going to go away.

Let us know if that's enough for the Spyder support you're trying to add to tqdm (and thanks for taking care of that, by the way).

@ccordoba12
Copy link
Member

Closing because I saw you followed my suggestion in your tqdm PR.

@ccordoba12 ccordoba12 closed this as not planned Won't fix, can't repro, duplicate, stale Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants