Skip to content

wxGUI: Support for Jupyter-based workflows#5901

Open
lindakarlovska wants to merge 85 commits intoOSGeo:mainfrom
lindakarlovska:new-jupyter-pane-in-gui
Open

wxGUI: Support for Jupyter-based workflows#5901
lindakarlovska wants to merge 85 commits intoOSGeo:mainfrom
lindakarlovska:new-jupyter-pane-in-gui

Conversation

@lindakarlovska
Copy link
Copy Markdown
Contributor

@lindakarlovska lindakarlovska commented Jun 17, 2025

This pull request introduces the support for running Jupyter notebooks directly within the GUI.

How it works

There is a new Launch Jupyter Notebook Environment button added to the top menu, right next to the Launch Python Editor button (In this PR, these workflow-related buttons are now grouped together, since all of them serve a similar purpose — working with scripts or automation workflows.)

When you click the Launch Jupyter Notebook button, a new dialog appears — Start Jupyter.
In this dialog, you can:

  • Choose whether to use the default working directory (created automatically in your current MAPSET as /notebooks), or
  • Select a custom directory where you have write access.

The working directory is very important because in this directory the Jupyter server will be launched which means that each running Jupyter server is tied to a single directory — meaning that your entire Jupyter session is associated with that directory. If you want to work in a different directory, you simply start another Jupyter session from the GUI.

Besides the selection of a working directory, there’s also an option to create a preconfigured “welcome” notebook (a template). This lets you start working immediately with GRASS and Jupyter already initialized — including automatic imports of GRASS scripting and Jupyter modules, and initialization of the session to match your current GRASS environment.

Screenshot from 2025-10-30 14-01-53

Once you confirm the dialog:
• A local Jupyter server is started.
• The status bar (bottom left corner) shows information such as the running port and the server PID.
• If you selected the template option, a welcome.ipynb file is created in the chosen working directory, already set up with an initialized GRASS Jupyter session.

Screenshot from 2025-11-03 13-30-38

Why the Working Directory Matters

A Jupyter server always requires a working directory.
By default, GRASS uses <MAPSET_PATH>/notebooks, since it’s always available and writable. In the first version of this PR, the directory was created automatically inside the mapset.
During the PSC meeting in August 2025 ( https://grasswiki.osgeo.org/wiki/PSC_Meeting_2025-08-08), we decided it would be better to:

  • Let users choose the working directory, and
  • Offer a simple way to start with a good default template notebook.

That’s why the new Start Jupyter dialog exists — it provides both of these options.

What if Jupyter Isn’t Available?
Two cases are handled:

  • Jupyter isn’t installed at all, or
  • The user is on Windows, where Jupyter isn’t yet integrated in the GRASS build.

In both cases, the Launch Jupyter Notebook button will be disabled.

Screenshot from 2025-10-28 12-12-57

If the user clicks it anyway, an explanatory message will be shown describing the issue.

Screenshot from 2025-10-30 13-44-54

Windows Support

In version 8.5, the “Launch Jupyter” button will be active only on UNIX systems.
To make it work on Windows (both OSGeo4W and the standalone installer), Jupyter needs to be included in the build process.
That’s not too difficult — Jupyter itself is already included in the standalone installer — but its dependencies (folium and ipyleaflet) are missing from OSGeo4W packages.
I’ve submitted a PR to add them (jef-n/OSGeo4W#36 ) but it’s still awaiting feedback.
Until this is resolved, Jupyter integration won’t be available on Windows in version 8.5.

Implementation Overview

  • python/grass/workflows/
    - directory.py
    Contains the JupyterDirectoryManager class, which manages Jupyter notebooks linked to the given working directory.
    Responsibilities include mainly: Import/export of .ipynb files and managing notebook templates (welcome.ipynb, new.ipynb).
    - server.py
    Provides two key classes: JupyterServerInstance which handles the lifecycle of an individual Jupyter server instance—installation check, port management, startup, shutdown, URL generation, etc. Also handles cleanup using atexit and signal handling to ensure servers are terminated when GRASS exits via GUI, exit, CTRL+C, or kill PID. Further, JupyterServerRegistry—a singleton that registers all active Jupyter server instances. It allows the global shutdown of all running servers when GRASS is closed from the GUI.
    - enviroment.py
    High-level orchestrator JupyterEnvironment integrates a working directory manager (template creation and file discovery), a Jupyter server instance and a registration of running servers in a global server registry
    - template_notebooks/
    - welcome.ipynb: A welcome notebook created on demand if checked in the Start Jupyter dialog (created only if the working directory is empty – no .ipynb files present)
    - new.ipynb: A template used when the user creates a new notebook via GUI

  • gui/wxpython/jupyter_notebook/
    - panel.py - defines the JupyterPanel class, which creates the interactive panel inside the GUI. It includes: A toolbar and an AuiNotebook widget that lists and displays .ipynb files from the working directory
    - notebook.py
    Class JupyterAuiNotebook—Handles logic for adding AUI notebook tabs with JavaScript injection for hiding the Jupyter File menu and header.
    - dialogs.py
    Class StartJupyterDialog with Jupyter startup settings.
    - toolbars.py
    Class JupyterToolbar—Implements the toolbar controls for notebook actions: Create new notebook, Import notebook, Export notebook, Dock/Undock, Quit

Additional Notes

  • Multiple Jupyter servers can run in a single GRASS session (one per panel)
  • All servers are automatically stopped when the GUI is closed or the session ends, even forcefully
  • Newly created notebooks (welcome.ipynb or new.ipynb) are pre-initialized with the GRASS Jupyter environment and required imports for immediate use. Welcome.ipynb has some extra info about a working directory.

Following steps

  • Enable Jupyter support on Windows once dependencies are available in OSGeo4W.
  • At some point, we should revisit the discussion about implementing a GRASS-specific Jupyter kernel — I still believe it makes sense (for example, ArcGIS Pro also provides its own). With such a kernel, users could run notebooks without need for manual initialization code. They could simply select the GRASS kernel and start working in the same way, no matter whether launching Jupyter from within the GUI or in a standalone browser session. Just noting this here for context — we’ve already talked about it briefly, but during the summit in May 2025, it felt too early to make a decision. Perhaps it still is (@petrasovaa, @landa, @wenzeslaus).
  • Having in mind that we aim to make Jupyter more accessible to users by enabling GUI integration, in the future, we could also consider introducing GRASS magic commands (IPython extensions) to make command-line operations easier in Jupyter.
    For example:
    %region save=myregion – Save region
    %mapinfo elevation  - Print info about a raster or vector map
    %info – Print info about current session
    %run r.slope.aspect elevation=elevation slope=slope aspect=aspect

These could become part of a grass.jupyter library.

@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from be55385 to 817795e Compare June 17, 2025 11:33
Comment thread python/grass/workflows/server.py Fixed
Comment thread python/grass/workflows/server.py Fixed
Comment thread python/grass/workflows/server.py Fixed
Comment thread python/grass/workflows/server.py Fixed
@github-actions github-actions bot added GUI wxGUI related Python Related code is in Python libraries docs notebook CMake labels Jun 17, 2025
Comment thread python/grass/workflows/server.py Fixed
@lindakarlovska
Copy link
Copy Markdown
Contributor Author

Just set up the discussion page for the notebook working directory topic and workflows topic in general: #5909.

@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 3a3b7e7 to 55974d3 Compare June 19, 2025 20:30
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch 2 times, most recently from 968784b to 9d30c42 Compare October 1, 2025 12:44
Comment thread python/grass/workflows/server.py Fixed
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 65e8ea7 to 08a1f06 Compare October 28, 2025 08:49
Comment thread python/grass/workflows/server.py Outdated
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch 3 times, most recently from 45af740 to adf7898 Compare November 2, 2025 06:01
@lindakarlovska lindakarlovska added this to the 8.5.0 milestone Nov 7, 2025
Comment thread python/grass/workflows/Makefile Outdated
@tmszi
Copy link
Copy Markdown
Member

tmszi commented Nov 16, 2025

Small note:

Under Gentoo GNU/Linux distribution I get error message when I hit Start Jupyter Notebook tool button:

ebook.py", line 21, in <module>
    import wx.html2 as html  # wx.html2 is available in
wxPython 4.0 and later
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/wx/html2.py", line
15, in <module>
    from ._html2 import *
ModuleNotFoundError: No module named 'wx._html2'
The above exception was the direct cause of the following
exception:
Traceback (most recent call last):
  File
"/usr/lib64/grass85/gui/wxpython/main_window/frame.py", line
911, in OnJupyterNotebook
    from jupyter_notebook.panel import JupyterPanel
  File
"/usr/lib64/grass85/gui/wxpython/jupyter_notebook/panel.py",
line 24, in <module>
    from .notebook import JupyterAuiNotebook
  File "/usr/lib64/grass85/gui/wxpython/jupyter_notebook/not
ebook.py", line 23, in <module>
    raise RuntimeError(_("wx.html2 is required for Jupyter
integration.")) from e
RuntimeError: wx.html2 is required for Jupyter integration.

I have install wxPython 4.x.x version:

GRASS world_latlong_wgs84/PERMANENT:~ > python -c "import wx;print(wx.version())"
4.2.3 gtk3 (phoenix) wxWidgets 3.2.8

wxPython import wx.html2 module is not available because wxPython and underlaying wxGTK library are not compiled with USE webkit flag. With enabled this flag module is available.

x11-libs/wxGTK library USE flags:

tomas@gentoo-gnu-linux:~$ equery u x11-libs/wxGTK
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for x11-libs/wxGTK-3.2.8.1-r2:
 U I
 + + X          : Add support for X11
 - - abi_x86_32 : 32-bit (x86) libraries
 - - curl       : Add support for client-side URL transfer library
 + + debug      : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
                  https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 - - doc        : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
 + + gstreamer  : Enable the wxMediaCtrl class for playing audio and video through gstreamer. 
 - - keyring    : Enable support for freedesktop.org Secret Service API password store
 + + libnotify  : Enable desktop notification support
 + + lzma       : Support for LZMA compression algorithm
 + + opengl     : Add support for OpenGL (3D graphics)
 + + sdl        : Use Simple Directmedia Layer (media-libs/libsdl) for audio. 
 + + spell      : Add dictionary support
 - - test       : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
 + + tiff       : Add support for the TIFF image format
 - - wayland    : Enable dev-libs/wayland backend
 + + webkit     : Add support for the WebKit HTML rendering/layout engine

dev-python/wxpython library USE flags:

tomas@gentoo-gnu-linux:~$ equery u dev-python/wxpython
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-python/wxpython-4.2.3-r2:
 U I
 - - debug                     : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
                                 https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 - - python_targets_python3_11 : Build with Python 3.11
 - - python_targets_python3_12 : Build with Python 3.12
 + + python_targets_python3_13 : Build with Python 3.13
 - - test                      : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
 + + webkit                    : Add support for the WebKit HTML rendering/layout engine

@tmszi
Copy link
Copy Markdown
Member

tmszi commented Nov 17, 2025

When I hit JupyterLab tool button from the Jupyter notebook toolbar, GRASS GIS window was killed.

jupyter_notebook_btn_link

Jupyter Interactive Notebook version =dev-python/notebook-7.4.7

Comment thread python/grass/workflows/server.py Outdated
Comment thread python/grass/workflows/server.py Outdated
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 2c2788d to 36fa2c4 Compare January 2, 2026 11:03
@lindakarlovska
Copy link
Copy Markdown
Contributor Author

lindakarlovska commented Jan 2, 2026

Small note:

Under Gentoo GNU/Linux distribution I get error message when I hit Start Jupyter Notebook tool button:

ebook.py", line 21, in <module>
    import wx.html2 as html  # wx.html2 is available in
wxPython 4.0 and later
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.13/site-packages/wx/html2.py", line
15, in <module>
    from ._html2 import *
ModuleNotFoundError: No module named 'wx._html2'
The above exception was the direct cause of the following
exception:
Traceback (most recent call last):
  File
"/usr/lib64/grass85/gui/wxpython/main_window/frame.py", line
911, in OnJupyterNotebook
    from jupyter_notebook.panel import JupyterPanel
  File
"/usr/lib64/grass85/gui/wxpython/jupyter_notebook/panel.py",
line 24, in <module>
    from .notebook import JupyterAuiNotebook
  File "/usr/lib64/grass85/gui/wxpython/jupyter_notebook/not
ebook.py", line 23, in <module>
    raise RuntimeError(_("wx.html2 is required for Jupyter
integration.")) from e
RuntimeError: wx.html2 is required for Jupyter integration.

I have install wxPython 4.x.x version:

GRASS world_latlong_wgs84/PERMANENT:~ > python -c "import wx;print(wx.version())"
4.2.3 gtk3 (phoenix) wxWidgets 3.2.8

wxPython import wx.html2 module is not available because wxPython and underlaying wxGTK library are not compiled with USE webkit flag. With enabled this flag module is available.

x11-libs/wxGTK library USE flags:

tomas@gentoo-gnu-linux:~$ equery u x11-libs/wxGTK
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for x11-libs/wxGTK-3.2.8.1-r2:
 U I
 + + X          : Add support for X11
 - - abi_x86_32 : 32-bit (x86) libraries
 - - curl       : Add support for client-side URL transfer library
 + + debug      : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
                  https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 - - doc        : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
 + + gstreamer  : Enable the wxMediaCtrl class for playing audio and video through gstreamer. 
 - - keyring    : Enable support for freedesktop.org Secret Service API password store
 + + libnotify  : Enable desktop notification support
 + + lzma       : Support for LZMA compression algorithm
 + + opengl     : Add support for OpenGL (3D graphics)
 + + sdl        : Use Simple Directmedia Layer (media-libs/libsdl) for audio. 
 + + spell      : Add dictionary support
 - - test       : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
 + + tiff       : Add support for the TIFF image format
 - - wayland    : Enable dev-libs/wayland backend
 + + webkit     : Add support for the WebKit HTML rendering/layout engine

dev-python/wxpython library USE flags:

tomas@gentoo-gnu-linux:~$ equery u dev-python/wxpython
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for dev-python/wxpython-4.2.3-r2:
 U I
 - - debug                     : Enable extra debug codepaths, like asserts and extra output. If you want to get meaningful backtraces see
                                 https://wiki.gentoo.org/wiki/Project:Quality_Assurance/Backtraces
 - - python_targets_python3_11 : Build with Python 3.11
 - - python_targets_python3_12 : Build with Python 3.12
 + + python_targets_python3_13 : Build with Python 3.13
 - - test                      : Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
 + + webkit                    : Add support for the WebKit HTML rendering/layout engine

To keep things consistent with the Windows behavior, in 2d7b550 I added a check for wx.html2 as well. When it’s not available, the Jupyter button is disabled and shows a message explaining why.

@lindakarlovska
Copy link
Copy Markdown
Contributor Author

@tmszi thanks very much for the review! and sorry for the later response. @petrasovaa could you also make the review please so that we can merge it and incorporate this feature to the 8.5 version?

@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 842ff18 to 590df4f Compare March 17, 2026 12:28
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 31b2a2b to ff48065 Compare March 20, 2026 21:39
@lindakarlovska
Copy link
Copy Markdown
Contributor Author

lindakarlovska commented Mar 23, 2026

I still see the JupyterLab button (and it crashes)...

@petrasovaa Which version of jupyter notebooks do you have?

I tested these versions of notebook: the newest 7.5.4, then 7.0.0, 6.0.0 and 5.0.0 - and regarding buttons I can see either this variant (versions 5 and 6): Screenshot from 2026-02-28 21-10-28
or this variant (7+): Screenshot from 2026-02-28 21-12-34
@petrasovaa How does it look like in your case and what is your notebook version?

Sorry for the late reply...
Screenshot_2026-03-13_10-39-14

jupyter                    1.1.1
jupyter_client             8.8.0
jupyter-console            6.6.3
jupyter_core               5.9.1
jupyter-events             0.12.0
jupyter-leaflet            0.20.0
jupyter-lsp                2.3.0
jupyter_server             2.17.0
jupyter_server_terminals   0.5.3
jupyterlab                 4.5.3
jupyterlab_pygments        0.3.0
jupyterlab_server          2.28.0
jupyterlab_widgets         3.0.16
notebook                   7.5.3

It was not actually caused by a different notebook or lab versions but by the fact that I have nbclassic installed which means that my InterfaceSwitcher looks different (it is a dropdown "Open In.." menu where two options are: nbclassic and jupyterlab - and it is a different JS class). I made the switcher more general - all these switchers should have the same name regardless of their classes. Does that work for you now @petrasovaa ?

@petrasovaa
Copy link
Copy Markdown
Contributor

It was not actually caused by a different notebook or lab versions but by the fact that I have nbclassic installed which means that my InterfaceSwitcher looks different (it is a dropdown "Open In.." menu where two options are: nbclassic and jupyterlab - and it is a different JS class). I made the switcher more general - all these switchers should have the same name regardless of their classes. Does that work for you now @petrasovaa ?

Yes, that seems to work!

petrasovaa
petrasovaa previously approved these changes Mar 24, 2026
Copy link
Copy Markdown
Contributor

@petrasovaa petrasovaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's merge this. Any chance we could test it on Windows?

Copy link
Copy Markdown
Member

@wenzeslaus wenzeslaus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good in terms of the code and it will need to be evaluated further in the wild. (Almost good to go.)

It would be great if someone who actually is in the target user group would evaluate this (now or after the merge). I'm using notebooks a lot, so I may also use them this way, but it will not change anything about how I do zero-install workshops or classes with things like Colab and Binder. My understanding is that Linda is trying to make impact in context where GRASS is used with GUI and without notebooks. I'm guessing @landam @pesekon2 others?

One small change still, I came up with a simpler, and hopefully also more informative, way of presenting the different links in the documentation. While the change is small in scale, it shows what is absolutely critical here: We should very carefully communicate what this is for and avoid creating a notion that one has to use the GUI in order to use GRASS+notebooks or that this is the integration of GRASS and Jupyter (it is the integration of notebooks into the GUI of GRASS).

Comment thread doc/jupyter_intro.md Outdated
Comment thread doc/jupyter_intro.md Outdated
Comment thread doc/jupyter_intro.md
Comment thread doc/jupyter_intro.md Outdated
@lindakarlovska
Copy link
Copy Markdown
Contributor Author

Let's merge this. Any chance we could test it on Windows?

Currently I am working on it, it is a big pain in general. I will be more specific soon.

@pesekon2
Copy link
Copy Markdown
Contributor

pesekon2 commented Apr 1, 2026

I am on holiday just with my phone, with no option to test it. If it stays open until late April, I can squeeze a quick test there after my arrival but unfortunately, no way to do it earlier at my side. Sorry.

But I fully agree with @wenzeslaus 's comment on making it clear that this is not the only nor mandatory way to use the notebooks within the GRASS environment.

…THON variable together with sys.executable used for all platforms
@lindakarlovska
Copy link
Copy Markdown
Contributor Author

Let's merge this. Any chance we could test it on Windows?

Currently I am working on it, it is a big pain in general. I will be more specific soon.

@petrasovaa, @wenzeslaus So, I am finally finished with testing on Windows – for a long time it seemed that the Integrated mode does not work even for Standalone or OSGeo4W – but I did not give up and was finally able to get it working at least for the Standalone variant.

To sum it up (I plan to include these hints in the docs as well):

Standalone installer
Tested on WinGRASS-8.5.0dev-b213ed3989-233-Setup.exe (2026-01-09, 935M) with manually copied code for Jupyter notebook GUI support. (The latest version on the wingrass server, WinGRASS-8.5.0dev-49c2d67434-256-Setup.exe (2026-02-05, 936M), appears to be broken – GRASS GUI does not start at all; I will investigate and open an issue or PR.)

I hoped that #6289 helped with including the notebook package to GRASS daily builds, but it seems that besides python3-jupyter also python3-notebook would need to be added. Therefore, after clicking on the Launch Jupyter Notebook button it fails with a Jupyter Notebook not installed error – we need to run from the Python GUI console:

import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "notebook"])

I also had multiple Jupyter installations on the machine, so originally used shutil.which("jupyter") executable proved unreliable (and also jupyter may be installed without jupyter notebook) – so it is safer to use the GRASS_PYTHON variable as the executable. I tested this on Linux as well and it works correctly, always picking the Jupyter notebook associated with GRASS.

After that, the Jupyter Startup dialog opens with two options – launching Jupyter Notebook in the default browser or the integrated solution directly in GRASS GUI.

  • Browser mode works great.

  • In Integrated mode, it is checked whether wx.html2.WebView uses Microsoft Edge WebView2 on Windows (as the necessary condition) – i.e. whether wxPython was built with that runtime support. Since the wxPython build is taken from the OSGeo4W wxPython build which lacks this support, Integrated mode will not work without reinstalling wxPython from pip, and the following error will be shown:
    Snímek obrazovky 2026-04-11 214403 - with the possible fallback to the Browser mode.

To make the Integrated mode functional, first, we need to check the current wx version:

import wx
print(wx.__version__)

and then force-reinstall wxPython from pip (for example, for version 4.2.2):

subprocess.check_call([
    sys.executable,
    "-m",
    "pip",
    "install",
    "--force-reinstall",
    "wxpython==4.2.2"
])

After that, the Integrated mode starts successfully.
Snímek obrazovky 2026-04-11 214547

OSGeo4W installer

Tested on the then-latest dev version of GRASS (fc1694e) by selecting the installation of "grass" package in Select packages dialog. The scripts for Jupyter notebook GUI support were then manually copied into the grass86 folder (similarly to the Standalone case).

The setup is similar to the official Jupyter guide: https://grass-tutorials.osgeo.org/content/tutorials/get_started/JupyterOnWindows_OSGeo4W_Tutorial.html#set-up. The key difference is that during the Advanced install, in the Select packages dialog, the python3-notebook package should ideally be explicitly selected as it is not installed by default. If forgotten, it can be installed afterwards in the OSGeo4W shell with pip install notebook. After that, the Jupyter Startup dialog successfully opens.

Here, the situation is as follows:

  • Browser mode works as expected.

  • Integrated mode is currently not functional because wxPython is not built with WebView2 support on the OSGeo4W side – more precisely, it looks like wxWidgets itself needs to be built with this support. I believe that this file needs to be edited: https://github.com/jef-n/OSGeo4W/blob/master/src/wxwidgets/osgeo4w/package.sh to also include the USE_WEBVIEW_EDGE=ON flag in the cmake command, maybe @wenzeslaus or @landam would know more?
    So for now, Integrated mode is not supported for the OSGeo4W installer - we will always get the fallback to the Browser mode.

Comment thread gui/wxpython/jupyter_notebook/server.py Outdated
Comment on lines +167 to +169
python,
"-m",
"notebook",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This python -m notebook replaced earlier, jupyter notebook. Is that intentional? python -m jupyter notebook would be the equivalent command.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, it is actually intentional since I had problems with running python -m jupyter notebook for the Standalone installer. For some reason, I still ended up with this output:

C:\Users\karlovskal>"C:\Program Files\GRASS 8.5\extrabin\python3.exe" -m jupyter --version
Selected Jupyter core packages...
IPython          : 9.12.0
ipykernel        : 7.2.0
ipywidgets       : 8.1.8
jupyter_client   : 8.8.0
jupyter_core     : 5.9.1
jupyter_server   : 2.17.0
jupyterlab       : 4.5.6
nbclient         : 0.10.4
nbconvert        : 7.17.1
nbformat         : 5.10.4
notebook         : 7.5.5
qtconsole        : not installed
traitlets        : 5.14.3

C:\Users\karlovskal>"C:\Program Files\GRASS 8.5\extrabin\python3.exe" -m jupyter notebook --version
Could not import runpy._run_module_as_main
Traceback (most recent call last):
  File "<frozen importlib._bootstrap>", line 1371, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1342, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 938, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1179, in exec_module
  File "<frozen runpy>", line 14, in <module>
  File "C:\Program Files\GRASS 8.5\Python312\Lib\importlib\__init__.py", line 57, in <module>
    import warnings
  File "C:\Program Files\GRASS [8.5\Python312\Lib\warnings.py"](http://8.0.0.5/Python312/Lib/warnings.py%22), line 591, in <module>
    filterwarnings("default", category=DeprecationWarning,
  File "C:\Program Files\GRASS [8.5\Python312\Lib\warnings.py"](http://8.0.0.5/Python312/Lib/warnings.py%22), line 155, in filterwarnings
    import re
  File "C:\Program Files\GRASS 8.5\Python312\Lib\re\__init__.py", line 125, in <module>
    from . import _compiler, _parser
  File "C:\Program Files\GRASS 8.5\Python312\Lib\re\_compiler.py", line 18, in <module>
    assert _sre.MAGIC == MAGIC, "SRE module mismatch"
AssertionError: SRE module mismatch

C:\Users\karlovskal>"C:\Program Files\GRASS 8.5\extrabin\python3.exe" -m notebook --version
7.5.5

I also tried to explicitly install jupyter notebook using C:\Users\karlovskal>"C:\Program Files\GRASS 8.5\extrabin\python3.exe" -m pip install jupyter notebook and the result of above-pasted output was the same. Moreover, after the installation all requirements already satisfied (nothing added), so I have no idea where the problem is (probably some environment problem?)

Anyway, I came to the conclusion that using python -m notebook command is just safer for users.

Interestingly, for the OSGeo4W installer i did not get the same error:

C:\OSGeo4W>python -m jupyter --version
Selected Jupyter core packages...
IPython          : 9.11.0
ipykernel        : 7.2.0
ipywidgets       : 8.1.8
jupyter_client   : 8.8.0
jupyter_core     : 5.9.1
jupyter_server   : 2.17.0
jupyterlab       : 4.5.6
nbclient         : 0.10.4
nbconvert        : 7.17.0
nbformat         : 5.10.4
notebook         : 7.5.5
qtconsole        : not installed
traitlets        : 5.14.3

C:\OSGeo4W>python -m jupyter notebook --version
7.5.5

C:\OSGeo4W>python -m notebook --version
7.5.5

@wenzeslaus
Copy link
Copy Markdown
Member

...it seems that besides python3-jupyter also python3-notebook would need to be added.

See my comment. Is it about which command you are running? Do you need to run that particular command?

...we need to run from the Python GUI console:

import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "notebook"])

You can also install it for the user, e.g. with a dialog/button, if it is that simple.

However, here it seems you switch from OSGeo4W packages to pip (even more relevant below for a OSGeo4W install). osgeo4w-setup.exe -q -k -P python3-notebook vs python pip install notebook.

...and also jupyter may be installed without jupyter notebook

Is it notebook or jupyter notebook which is not available (see above).

...so it is safer to use the GRASS_PYTHON variable as the executable.

I think it makes more sense to use sys.executable and ignore GRASS_PYTHON once you are in Python. The code will be simpler and it is more likely that we will keep it consistent across different places. GRASS_PYTHON is good when not in a Python process and Python is needed. In Python, sys.executable already points to the Python selected by the parent process (whether or not it is GRASS_PYTHON).

@lindakarlovska
Copy link
Copy Markdown
Contributor Author

lindakarlovska commented Apr 16, 2026

...it seems that besides python3-jupyter also python3-notebook would need to be added.

See my comment. Is it about which command you are running? Do you need to run that particular command?

...we need to run from the Python GUI console:

import subprocess
import sys
subprocess.check_call([sys.executable, "-m", "pip", "install", "notebook"])

You can also install it for the user, e.g. with a dialog/button, if it is that simple.

@wenzeslaus I tested the wxpython pip reinstall also for OSGeo4W instalator and it works as well. So I made two dialogs - the first one installs the notebook if not available and the second one reinstalls wxpython from pip to ensure the webview2 edge runtime support. Tested on standalone as well as OSGeo4W and works great - integrated mode is functional after the restart.

However, here it seems you switch from OSGeo4W packages to pip (even more relevant below for a OSGeo4W install). osgeo4w-setup.exe -q -k -P python3-notebook vs python pip install notebook.

...and also jupyter may be installed without jupyter notebook

Is it notebook or jupyter notebook which is not available (see above).

...so it is safer to use the GRASS_PYTHON variable as the executable.

I think it makes more sense to use sys.executable and ignore GRASS_PYTHON once you are in Python. The code will be simpler and it is more likely that we will keep it consistent across different places. GRASS_PYTHON is good when not in a Python process and Python is needed. In Python, sys.executable already points to the Python selected by the parent process (whether or not it is GRASS_PYTHON).

Yep, changed!

@lindakarlovska
Copy link
Copy Markdown
Contributor Author

@wenzeslaus I created the video how last changes works for the fresh standalone installation (it would look the same for OSGeo4W).

cil3.mp4

…tall from pip (to make integrated mode available)
@lindakarlovska lindakarlovska force-pushed the new-jupyter-pane-in-gui branch from 8de9431 to 87534c3 Compare April 17, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CMake docs GUI wxGUI related libraries markdown Related to markdown, markdown files notebook Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants