-
-
Notifications
You must be signed in to change notification settings - Fork 487
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
Fails running with Visual Studio Code Debugger on Windows #2
Comments
Maybe you've set another python version as default interpreter within vscode? Could you try running the following script from nicegui import ui
import nicegui
import sys
print(sys.version)
print(nicegui.__file__)
ui.run() and provide to output when running from command line vs vscode? |
Please note, that from version 0.4.0 NiceGUI requires a |
It fails on the import statement itself (either Here's the output when running to the above snippet:
So it's something to do with VSCode's debugger, but I've never seen this happen with anything else. |
Although it might be possible that the VSCode debugger conflicts with NiceGUI's internal reload detection mechanism, I'm struggling to reproduce the problem. When starting something like
with "Run">"Start Debugging">"Python File: Debug the currently active Python file", the Uvicorn server starts nicely, the browser opens a new tab on localhost:80 and I can set breakpoints (e.g. in the event handler of a simple button). Maybe VSCode runs the debugger differently on Windows than on Mac? |
An error in the import statement might have to do with the |
Sounds like that is causing the issue on my setup. Curious it works fine on yours. Perhaps it's a side effect of some extensions I've got loaded (a bunch of stuff for python/javascript/npm/react/etc.)? And like I said, it works fine without "debugging". I'm not a VSCode guru so I don't know what else to do here. You might want to see if anyone else can repro this, or it's just me. |
Right, so it's your code at config.py:41 that is causing this. Why it's not finding the ui.run() call in the main source I don't know. Also, it's opening 0.0.0.0 not localhost, which doesn't work. If I redirect to localhost it connects. |
I suspect that the debugger calls your main script with some wrapper and NiceGUI is looking for ui.run() in the wrong file. There are two things that would be of great help:
Maybe we need to add a new exception in And thanks for the hint about 0.0.0.0 vs. localhost. Although the server is starting with IP 0.0.0.0, the browser should open localhost. |
Here's the problem: Windows uses forward slashes, so your list of filenames to exclude needs to include names using them as well. Made that change and it works. |
Awesome! We totally forgot to use platform-independent file paths. I fixed it in Release 0.4.7. It also addresses the issue with Host 0.0.0.0. Thanks @DeviceNut for your contribution! |
Gives exception on import:
"Could not find ui.run() command"
But runs ok from command line.
This is on a Windows 10 Pro system.
The text was updated successfully, but these errors were encountered: