From 70b2902d10a7c6a1bc3f90156a29b7a5216b585c Mon Sep 17 00:00:00 2001 From: rht Date: Wed, 22 Nov 2023 03:13:43 -0500 Subject: [PATCH] fix: Do render_in_jupyter on Colab env --- mesa/experimental/jupyter_viz.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mesa/experimental/jupyter_viz.py b/mesa/experimental/jupyter_viz.py index d0843448906..c34a3d9fef3 100644 --- a/mesa/experimental/jupyter_viz.py +++ b/mesa/experimental/jupyter_viz.py @@ -152,7 +152,8 @@ def render_in_browser(): on_grid_layout=set_grid_layout, ) - if "ipykernel" in sys.argv[0]: + if ("ipykernel" in sys.argv[0]) or ("colab_kernel_launcher.py" in sys.argv[0]): + # When in Jupyter or Google Colab render_in_jupyter() else: render_in_browser()