-
-
Notifications
You must be signed in to change notification settings - Fork 475
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Runtime Error when trying to run native=True #1841
Comments
Strange. On Mac it's working fine. @JensOgorek could you check if the error is reproducible on your system? |
@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. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
I also encountered the same situation.Environment related information is as follows:
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)
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.) |
It works in windows via a virtual env. Had same error with wsl-ubuntu in a virtual env. |
same issue on |
Same issue here on Manjaro Linux. I installed pywebview with --break-system-packages |
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 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 #2419. |
Add to the top of your code:
On Linux I also had to |
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: 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. |
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:
Operating system is: Ubuntu 23.10 Installed via: @rodja sorry I somehow forgot to copy that into my post. |
Getting same issue Host: |
Getting same issue: Rocky 9.3 BUT, I cannot install what I need into the system, so, I am working out of a conda environment. |
Description
I'm getting a Fork vs Spawn error when attempting to run a native app on Ubuntu.
Sample Application (from documentation)
Invoked from command line from within a virtual environment: python main.py
Trackback
OS: Ubuntu 20.04
Python: 3.11.6
Pyenv: 2.3.29-5-g62e2e9c7
nicegui: 1.3.17
pywebview: 4.3.3
The text was updated successfully, but these errors were encountered: