简体   繁体   English

有没有办法检测笔记本显示在 voila、jupyter 或 jupyterlab 中?

[英]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.

相关问题 在没有Jupyter Notebook的情况下打开JupyterLab? - Open JupyterLab without Jupyter Notebook? JupyterLab/Jupyter Notebook 无法在浏览器中正常打开 - JupyterLab/Jupyter Notebook not opening properly in browser 如何在 Jupyter notebook 或 JupyterLab 中使用破折号? - How to use dash within Jupyter notebook or JupyterLab? Jupyter Notebook 和 JupyterLab 有什么区别? - What is the difference between Jupyter Notebook and JupyterLab? 我安装了 python 3.9.1 但无法打开 jupyter notebook 或 jupyterlab - I installed python 3.9.1 but can not open jupyter notebook or jupyterlab 使用 Anaconda - 可以将 numpy 导入 Jupyterlab 但不能导入 Jupyter 笔记本 - Using Anaconda - Can import numpy into Jupyterlab but not Jupyter notebook Jupyterlab:目录不断重定向到 jupyter_notebook_config.py 所在的位置 - Jupyterlab: Directory keeps redirecting to where jupyter_notebook_config.py is 如何在 Jupyter Notebook 或 JupyterLab 单元格中运行单行或选定代码? - How to run a single line or selected code in a Jupyter Notebook or JupyterLab cell? 在 MacOS big sur 上安装 jupyterlab/jupyter notebook 时出错 - Error installing jupyterlab/jupyter notebook on MacOS big sur 如何在 JupyterLab 或 Jupyter Notebook 中找回代码块 - How to find back a code block in JupyterLab or Jupyter Notebook
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM