nicegui icon indicating copy to clipboard operation
nicegui copied to clipboard

Runtime Error when trying to run native=True

Open swrpug opened this issue 2 years ago • 26 comments

Description

I'm getting a Fork vs Spawn error when attempting to run a native app on Ubuntu.

Sample Application (from documentation)

from nicegui import app, ui

app.native.window_args['resizable'] = False
app.native.start_args['debug'] = True

ui.label('app running in native mode')
ui.button('enlarge', on_click=lambda: app.native.main_window.resize(1000, 700))

ui.run(native=True, window_size=(400, 300), fullscreen=False)

Invoked from command line from within a virtual environment: python main.py

Trackback

Traceback (most recent call last):
  File "/mnt/ext3tbdrive/sandbox/try-nicegui/main.py", line 15, in <module>
    main()
  File "/mnt/ext3tbdrive/sandbox/try-nicegui/main.py", line 11, in main
    ui.run(native=True, window_size=(400, 300), fullscreen=False)
  File "/mnt/ext3tbdrive/sandbox/try-nicegui/env/lib/python3.11/site-packages/nicegui/run.py", line 180, in run
    ChangeReload(config, target=globals.server.run, sockets=[sock]).run()
  File "/mnt/ext3tbdrive/sandbox/try-nicegui/env/lib/python3.11/site-packages/uvicorn/supervisors/basereload.py", line 49, in run
    self.startup()
  File "/mnt/ext3tbdrive/sandbox/try-nicegui/env/lib/python3.11/site-packages/uvicorn/supervisors/basereload.py", line 85, in startup
    self.process.start()
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/process.py", line 121, in start
    self._popen = self._Popen(self)
                  ^^^^^^^^^^^^^^^^^
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/context.py", line 288, in _Popen
    return Popen(process_obj)
           ^^^^^^^^^^^^^^^^^^
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 32, in __init__
    super().__init__(process_obj)
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/popen_fork.py", line 19, in __init__
    self._launch(process_obj)
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/popen_spawn_posix.py", line 47, in _launch
    reduction.dump(process_obj, fp)
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
  File "/home/tim/.pyenv/versions/3.11.6/lib/python3.11/multiprocessing/synchronize.py", line 107, in __getstate__
    raise RuntimeError('A SemLock created in a fork context is being '
RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.

OS: Ubuntu 20.04 Python: 3.11.6 Pyenv: 2.3.29-5-g62e2e9c7 nicegui: 1.3.17 pywebview: 4.3.3

swrpug avatar Oct 19 '23 20:10 swrpug

Strange. On Mac it's working fine. @JensOgorek could you check if the error is reproducible on your system?

rodja avatar Oct 20 '23 02:10 rodja

@rodja I just saw this. Can confirm an error. It starts normally, but clicking on enlarge causes connection lost at nicegui version 1.3.17 and on 1.4.1.

JensOgorek avatar Oct 27 '23 07:10 JensOgorek

On the Windows 11, it requires webview to run

image

microsoft code log

PowerShell 7.3.8
PS C:\Users\mbedir\Desktop\niceekran>  & 'C:\Program Files\Python311\python.exe' 'c:\Users\mbedir\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '61418' '--' 'C:\Users\mbedir\Desktop\niceekran\destopapp.py'
PS C:\Users\mbedir\Desktop\niceekran>  c:; cd 'c:\Users\mbedir\Desktop\niceekran'; & 'C:\Program Files\Python311\python.exe' 'c:\Users\mbedir\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '61442' '--' 'C:\Users\mbedir\Desktop\niceekran\destopapp.py'

Native mode is not supported in this configuration.
Please run "pip install pywebview" to use it.
PS C:\Users\mbedir\Desktop\niceekran> pip install pywebview  
Defaulting to user installation because normal site-packages is not writeable
DEPRECATION: Loading egg at c:\program files\python311\lib\site-packages\vboxapi-1.0-py3.11.egg is deprecated. pip 23.3 will enforce this behaviour change. A possible replacement is to use pip for package installation..
Collecting pywebview
  Obtaining dependency information for pywebview from https://files.pythonhosted.org/packages/94/eb/fec1105c0e3b459266637bdc867bd064619eddb170dc0c9d12f20ad7690c/pywebview-4.4.1-py3-none-any.whl.metadata
  Downloading pywebview-4.4.1-py3-none-any.whl.metadata (4.0 kB)
Collecting proxy-tools (from pywebview)
  Downloading proxy_tools-0.1.0.tar.gz (3.0 kB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: bottle in c:\users\mbedir\appdata\roaming\python\python311\site-packages (from pywebview) (0.12.23)
Requirement already satisfied: typing-extensions in c:\users\mbedir\appdata\roaming\python\python311\site-packages (from pywebview) (4.8.0)
Collecting pythonnet (from pywebview)
  Obtaining dependency information for pythonnet from https://files.pythonhosted.org/packages/12/28/2ecca48b313c436eb0b194b74b5a70dd88f2700d79bce5424799ffc82ede/pythonnet-3.0.3-py3-none-any.whl.metadata
  Downloading pythonnet-3.0.3-py3-none-any.whl.metadata (6.6 kB)
Collecting clr-loader<0.3.0,>=0.2.6 (from pythonnet->pywebview)
  Obtaining dependency information for clr-loader<0.3.0,>=0.2.6 from https://files.pythonhosted.org/packages/b3/1a/2801c4e3888aac8fcd4d88d32a1155a778d1c01ca040ae8137d433a39cc6/clr_loader-0.2.6-py3-none-any.whl.metadata
  Downloading clr_loader-0.2.6-py3-none-any.whl.metadata (1.4 kB)
Requirement already satisfied: cffi>=1.13 in c:\users\mbedir\appdata\roaming\python\python311\site-packages (from clr-loader<0.3.0,>=0.2.6->pythonnet->pywebview) (1.15.1)
Requirement already satisfied: pycparser in c:\users\mbedir\appdata\roaming\python\python311\site-packages (from cffi>=1.13->clr-loader<0.3.0,>=0.2.6->pythonnet->pywebview) (2.21)
Downloading pywebview-4.4.1-py3-none-any.whl (405 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 405.9/405.9 kB 1.9 MB/s eta 0:00:00
Downloading pythonnet-3.0.3-py3-none-any.whl (290 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 291.0/291.0 kB 3.0 MB/s eta 0:00:00
Downloading clr_loader-0.2.6-py3-none-any.whl (51 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 51.3/51.3 kB 1.3 MB/s eta 0:00:00
Building wheels for collected packages: proxy-tools
  Building wheel for proxy-tools (setup.py) ... done
  Created wheel for proxy-tools: filename=proxy_tools-0.1.0-py3-none-any.whl size=2913 sha256=8b3a53f5a99ad97b8c2394db2a73ef5523255a24e849ee13b0db7091d9012d90
  Stored in directory: c:\users\mbedir\appdata\local\pip\cache\wheels\2b\5f\96\7e96e7cbf06e426e168a6891a6ca2226787cc79fc816830dd4
Successfully built proxy-tools
Installing collected packages: proxy-tools, clr-loader, pythonnet, pywebview
Successfully installed clr-loader-0.2.6 proxy-tools-0.1.0 pythonnet-3.0.3 pywebview-4.4.1

[notice] A new release of pip is available: 23.2.1 -> 23.3.1
[notice] To update, run: python.exe -m pip install --upgrade pip
PS C:\Users\mbedir\Desktop\niceekran>  c:; cd 'c:\Users\mbedir\Desktop\niceekran'; & 'C:\Program Files\Python311\python.exe' 'c:\Users\mbedir\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '61479' '--' 'C:\Users\mbedir\Desktop\niceekran\destopapp.py'

0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
NiceGUI ready to go on http://localhost:8000 (install netifaces to show all IPs and speedup this message)
[pywebview] Using WinForms / Chromium
PS C:\Users\mbedir\Desktop\niceekran>  c:; cd 'c:\Users\mbedir\Desktop\niceekran'; & 'C:\Program Files\Python311\python.exe' 'c:\Users\mbedir\.vscode\extensions\ms-python.python-2023.18.0\pythonFiles\liions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '6154ions\ms-python.python-2023.18.0\pythonFiles\lib\python\debugpy\adapter/../..\debugpy\launcher' '61543' '--' 'C:\Users\mbedir\Desktop\niceekran\destopapp.py'
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
0.01s - Debugger warning: It seems that frozen modules are being used, which may
0.00s - make the debugger miss breakpoints. Please pass -Xfrozen_modules=off
0.00s - to python to disable frozen modules.
0.00s - Note: Debugging will proceed. Set PYDEVD_DISABLE_FILE_VALIDATION=1 to disable this validation.
NiceGUI ready to go on http://localhost:8000 (install netifaces to show all IPs and speedup this message)
[pywebview] Using WinForms / Chromium

muratbedir avatar Nov 01 '23 06:11 muratbedir

Native mode is not supported in this configuration.
Please run "pip install pywebview" to use it.

@muratbedir Yes the message is expected because we made pywebview an optional dependency. It has nothing to do with this issue.

rodja avatar Nov 01 '23 07:11 rodja

I also encountered the same situation.Environment related information is as follows:

  • OS Version:ArchLinux Linux 6.5.9-arch2-1
  • Python Version: 3.11.5
  • NiceGUI Version:1.4.1

When I execute the following code in the venv virtual environment, python will report an error:

from nicegui import app, ui

app.native.window_args['resizable'] = False
app.native.start_args['debug'] = True

ui.label('app running in native mode')
ui.button('enlarge', on_click=lambda: app.native.main_window.resize(1000, 700))

ui.run(native=True, window_size=(400, 300), fullscreen=False)
Traceback(part):
  File "/usr/lib/python3.11/multiprocessing/reduction.py", line 60, in dump
    ForkingPickler(file, protocol).dump(obj)
  File "/usr/lib/python3.11/multiprocessing/synchronize.py", line 107, in __getstate__
    raise RuntimeError('A SemLock created in a fork context is being '
RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.

Because pip cannot be used to directly install python packages under ArchLinux (it will conflict with pacman), and there is no packaged python-nicegui package, so I have been developing in a virtual environment. I used to think that the error was due to executing NiceGUI in a virtual environment, but after reading this article, I tend to think that it is due to incorrect configuration of multiprocessing.(However, I still recommend that you directly use the system python environment to execute the NiceGUI code in a Linux distribution that can use pip to determine whether this problem can be reproduced.)

fdawnxl avatar Nov 05 '23 03:11 fdawnxl

It works in windows via a virtual env. Had same error with wsl-ubuntu in a virtual env.

dev-robasi avatar Jan 11 '24 01:01 dev-robasi

same issue on system: Linux 6.5.13-7-MANJARO python: 3.12.1 python installed with pyenv using virtual env

nimmadev avatar Jan 15 '24 22:01 nimmadev

Same issue here on Manjaro Linux. I installed pywebview with --break-system-packages

ahdeddd avatar Jan 18 '24 04:01 ahdeddd

1."RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context." issue is not happened when running the following sample on my host with Python 3.10 and nicegui (both 1.3.17 & 1.4.12).

// On host Operating System: Ubuntu 22.04.3 LTS
Kernel: Linux 6.5.0-14-generic Python: 3.10.13 nicegui: 1.3.17/1.4.12 pywebview: 4.4.1

from nicegui import app, ui

app.native.window_args['resizable'] = False
app.native.start_args['debug'] = True

ui.label('app running in native mode')
ui.button('enlarge', on_click=lambda: app.native.main_window.resize(1000, 700))

ui.run(native=True, window_size=(400, 300), fullscreen=False)

2.But I will have another issue when running nicegui with "native=True": Connection terminated unexpectedly, as described https://github.com/zauberzeug/nicegui/issues/2419.

yuanxion avatar Jan 23 '24 02:01 yuanxion

Add to the top of your code:

import multiprocessing
multiprocessing.set_start_method("spawn", force=True)

On Linux I also had to pip install qtpy pyqt5 PyQtWebEngine

electronstudio avatar Feb 14 '24 01:02 electronstudio

I've tried the method above, but NicuGUI still throws the same error as before. I think this might be a venv issue. So I created an ubuntu virtual machine (with Gnome desktop) and installed NiceGUI and pywebview in the system python environment. After I installed the relevant dependencies of pywebview, I directly executed the sample code on the homepage. Surprisingly, the program was executed successfully:

Screenshot from 2024-02-15 00-01-24

Since I did not use the same system and kernel as the host machine(Arch Linux, linux-zen) when I created the virtual machine(Ubuntu, linux), I cannot find the problem by controlling variables for the time being. However, this may indicate that there is no problem with the code of NiceGUI itself. By the way, when using pywebview, you may get an error due to missing dependencies. You can refer to this URL to solve this problem.

fdawnxl avatar Feb 14 '24 16:02 fdawnxl

Using:

from nicegui import app, ui
import multiprocessing
multiprocessing.set_start_method("spawn", force=True)

app.native.window_args['resizable'] = False
app.native.start_args['debug'] = True

ui.label('app running in native mode')
ui.button('enlarge', on_click=lambda: app.native.main_window.resize(1000, 700))

ui.run(native=True, window_size=(400, 300), fullscreen=False)

Getting Error:

RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.

Operating system is: Ubuntu 23.10

Installed via: python3 -m pip install pywebview nicegui qtpy pyqt5 PyQtWebEngine

@rodja sorry I somehow forgot to copy that into my post.

initiateit avatar Mar 06 '24 02:03 initiateit

Getting same issue

Host: Operating System: EndeavourOS x86_64 Kernel: 6.8.7-zen1-1-zen Python: 3.11.8 nicegui: 1.4.15 pywebview: 5.1

Aikufurr avatar Apr 24 '24 09:04 Aikufurr

Getting same issue:

Rocky 9.3 Python 3.11.9 Nicegui 1.4.25 pywebview 5.1

BUT, I cannot install what I need into the system, so, I am working out of a conda environment.

gsal avatar May 23 '24 19:05 gsal

Same issue EndeavourOS x86_64

pywebview: 5.1 nicegui: 1.4.26 python: 3.12.3

Tried to install python-pywebview from AUR to possibly bring in any dependencies missing. Still no luck. AUR

StephanieSunshine avatar Jun 09 '24 13:06 StephanieSunshine

Here is how I got it working using venv (Using Arch Linux):

python -m venv venv
source venv/bin/activate
pip install nicegui pywebview qtpy pyqt5 PyQtWebEngine

Here is the code I was able to run without issue.

import multiprocessing
multiprocessing.set_start_method("spawn", force=True)
from nicegui import app, ui

app.native.window_args['resizable'] = False
app.native.start_args['debug'] = True

ui.label('app running in native mode')
ui.button('enlarge', on_click=lambda: app.native.main_window.resize(1000, 700))

ui.run(native=True, window_size=(400, 300), fullscreen=False)

Note: I only saw the error other reported above if:

import multiprocessing
multiprocessing.set_start_method("spawn", force=True)

Came after:

from nicegui import app, ui

knoppmyth avatar Jul 01 '24 05:07 knoppmyth

I've kind of given up on running my nicegui app in native mode on Ubuntu 24.04.1. Also had the SemLock issue. I did get it running with the suggested packages and multiprocessing import from @knoppmyth but the app scales extremely weird and small even if I stretch it to the full size of the screen.

Trying the most basic, 3 lines pywebview, application does the same: image

frankhuurman avatar Oct 01 '24 20:10 frankhuurman

pywebview 5.3 just got released. Can anyone check if the problem persists?

falkoschindler avatar Oct 17 '24 07:10 falkoschindler

Yes, problem persists ... but it is a VSCode terminal problem. If you run program using linux standard terminal ( shell ) the problem doesn't exists. The only warning appears at the end of program execution:

/usr/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown warnings.warn('resource_tracker: There appear to be %d '

I use Ubuntu 24.04.1, and pywebview 5.3.2 under venv , and I follow the knoppmyth solution .

In VScode environment I installed : pywebview qtpy pyqt5 PyQtWebEngine pycairo PyGObject to try to solve problem but it persists .

A little quirk could be used to solve the first main exception of the program: try to unset the variable GTK_PATH in VSCode terminal, the first exception disappears, but some others problems arises after this quirk.

In VsCode terminal the same program said:

NiceGUI ready to go on http://localhost:8000 [pywebview] Using GTK Gtk-Message: 10:35:45.385: Failed to load module "canberra-gtk-module" /usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/WebKitNetworkProcess: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE Gtk-Message: 10:35:45.649: Failed to load module "canberra-gtk-module" Gtk-Message: 10:35:45.650: Failed to load module "canberra-gtk-module" Gtk-Message: 10:35:45.673: Failed to load module "canberra-gtk-module" Gtk-Message: 10:35:45.675: Failed to load module "canberra-gtk-module" /usr/lib/x86_64-linux-gnu/webkit2gtk-4.1/WebKitNetworkProcess: symbol lookup error: /snap/core20/current/lib/x86_64-linux-gnu/libpthread.so.0: undefined symbol: __libc_pthread_init, version GLIBC_PRIVATE ERROR: WebKit encountered an internal error. This is a WebKit bug. ./Source/WebKit/WebProcess/Network/WebLoaderStrategy.cpp(562) : internallyFailedLoadTimerFired

So the problem seems to be located only in the VSCode environment and not in venv environment used by python and requested by Ubuntu .

Here you can see the correct execution of knopmyth snippet under linux shell terminal

Schermata del 2024-11-06 10-46-01

Qhawaq avatar Nov 06 '24 09:11 Qhawaq

I faced the exact same error when running with ui.run(native=True) on Ubuntu 24.04 while running inside a python venv in a terminal window. The following worked to fix the error

Step 1: Adding the following lines at the very start of the python script, before from nicegui import ui

import multiprocessing
multiprocessing.set_start_method("spawn", force=True)

Step 2: (I had installed pywebview in the venv with pip install pywebview). I had to additionally do pip install pywebview[qt]

After that, I was able to run the nicegui app as a native app with no weird appearance issues.

For what it's worth, after closing the native window (by pressing the X in the window titlebar), the following message appears in the console. I don't know if it is particularly important.

/usr/lib/python3.12/multiprocessing/resource_tracker.py:254: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown
  warnings.warn('resource_tracker: There appear to be %d '

sagarbehere avatar Jan 17 '25 06:01 sagarbehere

@sagarbehere

installed the same packages as you but on Arch Linux & Python 3.13, even if it has the "qt" libraries installed pywebview still seems to search for the GTK libs:

(venv) [frank@codingthing pyprojects]$ python app.py
NiceGUI ready to go on http://localhost:8000
[pywebview] GTK cannot be loaded
Traceback (most recent call last):
  File "/home/frank/pyprojects/venv/lib/python3.13/site-packages/webview/guilib.py", line 37, in import_gtk
    import webview.platforms.gtk as guilib
  File "/home/frank/pyprojects/venv/lib/python3.13/site-packages/webview/platforms/gtk.py", line 20, in <module>
    import gi
ModuleNotFoundError: No module named 'gi'
(venv) [frank@codingthing pyprojects]$ /usr/lib/python3.13/multiprocessing/resource_tracker.py:276: UserWarning: resource_tracker: There appear to be 6 leaked semaphore objects to clean up at shutdown: {'/mp-vq207iti', '/mp-64bdpzsk', '/mp-0e4qk06e', '/mp-5hddrepa', '/mp-cbmscziu', '/mp-caime8fw'}
  warnings.warn(

And have the same leaked semaphore objects warning as you.

But besides those warnings, it does seem to work now with native mode so thanks for that 😄 Will have to build something more complex to see if that works!

frankhuurman avatar Feb 02 '25 22:02 frankhuurman

Was review issues and heard "leaked semaphore" multiple times in this thread.

So, I suggest going to NiceGUI 2.16.0 for https://github.com/zauberzeug/nicegui/pull/4653

evnchn avatar May 03 '25 20:05 evnchn

I managed to get this working.

I'm running Fedora i3 with Nvidia Proprietary drivers and Picom compositor in a venv with python3.11

Here's what I did:

Update to newest version of nicegui

pip install --upgrade nicegui

Install GTK pygobject

I then got an error that there was no module named 'gi' -> See @frankhuurman response above Googling this -> GTK GObject Introspection python bindings are not working so I tried installing these pip install pygobject This did not work for me because of a meson build error.

Install dev tools if above doesn't work

Double check dependencies are installed - dnf install python3-devel cairo-devel gobject-introspection-devel
If you're on ubuntu or something else you'll need to look up the equivalent libraries Make sure to install the correct version of python3-devel (or ubuntu equivalent) for you venv - In my case I was a bit of an idiot because my venv is using 3.11 and system python is 3.13. So for me I had to install sudo dnf install python3.11-devel Meson will fail to find python otherwise After this re-install pip install --force-reinstall --no-cache-dir pycairo pygobject

Additional issues

I also had a GBM buffer issue -> This is GTK nvidia thing. To get it working I had to run WEBKIT_DISABLE_COMPOSITING_MODE=1 GDK_BACKEND=x11 python app.py

MrGibus avatar May 10 '25 05:05 MrGibus

pywebview 6.1 just got released. Can anyone check if the problem persists after upgrading pywebview as well as NiceGUI? Thanks!

falkoschindler avatar Oct 22 '25 08:10 falkoschindler

Yes, the issue still exist. Still works as noted above https://github.com/zauberzeug/nicegui/issues/1841#issuecomment-2199268613

knoppmyth avatar Oct 22 '25 08:10 knoppmyth

Yup, still exists. Python 3.13.7 with a fresh virtual env and NiceGUI version 3.2.0 first points me to install pywebview to be able to use native mode. After installing that and running again it tells me webview.errors.WebViewException: You must have either QT or GTK with Python extensions installed in order to use pywebview.

Then after installing PyGObject and running again I get the dreaded semlock error:

RuntimeError: A SemLock created in a fork context is being shared with a process in a spawn context. This is not supported. Please use the same context to create multiprocessing objects and Process.

NiceGUI native mode on Linux only seems to work if you put this somewhere in your imports, for me it does not matter if it's before or after importing nicegui:

import multiprocessing
multiprocessing.set_start_method('spawn', force=True)

frankhuurman avatar Nov 08 '25 21:11 frankhuurman