-
Notifications
You must be signed in to change notification settings - Fork 295
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
Provide way to determine if running in VS Code Interactive Notebook #7380
Comments
I answered this in the discussion but the only way to do this now is to examine the environment of the launched kernel. It will contain VS code environment variables (for local kernels). We could potentially add another environment variable to a kernel that says something like - VS_CODE_STARTED_KERNEL |
Panel 0.12 used the information from this discussion to support VS Code out of the NOx. Thanks for the help 👍 |
@MarcSkovMadsen can you try to use the environment variable |
Closing this issue for now, please feel free to re-open or create a new issue if this doesn't work |
Discussed in microsoft/vscode-python#16034
Originally posted by MarcSkovMadsen April 24, 2021
I am a user of and contributor to HoloViz Panel. Panel is a framework for interactive exploratory data analysis and for building powerful analytics apps (see https://awesome-panel.org).
Panel builds on the Bokeh ecosystem and Panel provides full interactivity in the VS Code Interactive Notebook environment if I set
pn.extension(comms='vscode')
at the top of my code. See the Panel - VS Code docs.My pain is that I and the users I develop notebooks for work in many environments Notebook, Labs, VS Code, PyCharm, Colab and deploy to many servers Bokeh/ Panel, Voila, Flask, Django etc. And the line of code
pn.extension(comms='vscode')
should not be added in any environment but the VS Code Interactive Notebook environment.So I need a way to programmatically determine if the code is running in the VS Code Interactive Notebook environment.
Solution
Please tell me how to programmatically from python determine if I am running in VS Code Interactive Notebook or develop something that can tell me.
Thanks
Additional Context
I tried printing
sys.modules
to see if somethingvs code python extension
specific is loaded. But without luck.I have also tried Google and Github to find an answer without luck.
Not working with 3.0
Panel is currently not working in VS Code with jupyter >= 3.0 c.f. bokeh/jupyter_bokeh#131. Some js package needs to be deployed to npm.
Panel and VS Code is a super powerful combination
The below is something you can develop with Panel. It can also run interactively inside Notebooks and VS Code. And it even lets you start additional servers via
.show()
method on Panel objects so that can open and update windows outside of VS Code from the Interactive Notebook. I.e. circumventing the problem of VS Code not really supporting working efficiently with multiple windows".deckgl_binder.mp4
It also has a powerful
--autoreload
function for users for hot reloading of.py
and.ipynb
files. Which makes it super powerful for working with VS Code and Python.The text was updated successfully, but these errors were encountered: