Is there a way to detect that notebook is displayed in voila, jupyter or jupyterlab?
Asked Answered
C

1

2

I'm using the xarray_leaflet library that has has a different behavior if the notebook is launch with voila, jupyter or jupyterLab.

Is there a way to detect it programmatically ?

Calvary answered 4/11, 2020 at 8:6 Comment(0)
F
2

In versions of voila > .2, there are a bunch of environmental variables on the running environment (e.g. 'QUERY_STRING', 'SERVER_SOFTWARE', 'SERVER_PROTOCOL', 'SERVER_PORT', 'PATH_INFO', 'SERVER_NAME', 'SCRIPT_NAME'), so detecting if you are running in voila is as simple as checking if any of those exist, or even better:

import os
running_in_voila = os.environ.get('SERVER_SOFTWARE','jupyter').startswith('voila')
Forgo answered 24/5, 2021 at 8:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.