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

Recommended way to reliably detect if jupyter is running inside vscode? #3364

Closed
songololo opened this issue Jun 2, 2019 · 3 comments
Closed

Comments

@songololo
Copy link

When running jupyter inside vscode the tqdm module's auto notebook functionality will break. See this related issue: tqdm/tqdm#747

Hence this question: Is there a recommended (and future-proof) way to reliably detect when jupyter is running inside vscode so that imported modules can be set-up accordingly?

From running os.environ inside a jupyter notebook running inside vscode the following environment variables look like potential candidates for flagging these situations:

'VSCODE_NODE_CACHED_DATA_DIR': '...'
'VSCODE_PREVENT_FOREIGN_INSPECT': 'true',
'VSCODE_LOGS': '...',
'VSCODE_HANDLES_UNCAUGHT_ERRORS': 'true',
'VSCODE_IPC_HOOK_EXTHOST': '...',
'VSCODE_NLS_CONFIG': '{"locale":"en-gb","availableLanguages":},"_languagePackSupport":true}',
'VSCODE_IPC_HOOK': '.../1.34.0-main.sock',
'VSCODE_PID': '94309'

Would one of these, e.g. VSCODE_PID be sufficient for this purpose?

@rchiodo
Copy link
Contributor

rchiodo commented Jun 3, 2019

Yes I believe VSCODE_PID would only be valid if the jupyter notebook was started from within VS Code.

@songololo
Copy link
Author

@rchiodo do you possibly know in what ways the vscode functionality for jupyter works differently from the vanilla version running inside a browser?

I ask from the point of view of trying to understand why the tqdm auto notebook progress bar functionality doesn't work the same way.

@rchiodo
Copy link
Contributor

rchiodo commented Jun 5, 2019

That's a hard question to answer. It depends.

Some of the differences are CSS styles that we apply to output.
Some of the differences are our VS Code extension isn't handling all of the Jupyter communication correctly.

Do you have some example code for the tqdm auto progress bar? I may have just fixed the tqdm progress bar:
https://github.com/microsoft/vscode-python/issues/5801

@lock lock bot locked as resolved and limited conversation to collaborators Jun 12, 2019
@microsoft microsoft unlocked this conversation Nov 14, 2020
@DonJayamanne DonJayamanne transferred this issue from microsoft/vscode-python Nov 14, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants