[英]Is there a way to detect that notebook is displayed in voila, jupyter or jupyterlab?
I'm using the xarray_leaflet library that has has a different behavior if the notebook is launch with voila, jupyter or jupyterLab.如果笔记本是通过 voila、jupyter 或 jupyterLab 启动的,我正在使用xarray_leaflet库,该库具有不同的行为。
Is there a way to detect it programmatically ?有没有办法以编程方式检测它?
In versions of voila > .2
, there are a bunch of environmental variables on the running environment (eg '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:在 voila >
.2
版本中,运行环境中有一堆环境变量(例如'QUERY_STRING', 'SERVER_SOFTWARE', 'SERVER_PROTOCOL', 'SERVER_PORT', 'PATH_INFO', 'SERVER_NAME', 'SCRIPT_NAME'
),因此,检测您是否正在运行就像检查其中是否存在一样简单,甚至更好:
import os
running_in_voila = os.environ.get('SERVER_SOFTWARE','jupyter').startswith('voila')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.