Skip to content

Instantly share code, notes, and snippets.

@manics
Last active March 11, 2026 10:40
Show Gist options
  • Select an option

  • Save manics/ee42a681612dd880311927abec359627 to your computer and use it in GitHub Desktop.

Select an option

Save manics/ee42a681612dd880311927abec359627 to your computer and use it in GitHub Desktop.
#!/srv/conda/envs/notebook/bin/python
import os
import sys
try:
import jupyterlab
import jupyterlab.labapp
major = int(jupyterlab.__version__.split(".", 1)[0])
except Exception as e:
print("Failed to import jupyterlab: {e}", file=sys.stderr)
have_lab = False
else:
have_lab = major >= 3
if have_lab:
# technically, we could accept another jupyter-server-based frontend
print("Launching jupyter-lab", file=sys.stderr)
exe = "jupyter-lab"
else:
print("jupyter-lab not found, launching jupyter-notebook", file=sys.stderr)
exe = "jupyter-notebook"
# launch the notebook server
os.execvp(exe, sys.argv)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment