Skip to content
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

Dll not found error when opening native window #576

Closed
Skjolbir opened this issue Mar 20, 2023 · 7 comments
Closed

Dll not found error when opening native window #576

Skjolbir opened this issue Mar 20, 2023 · 7 comments

Comments

@Skjolbir
Copy link

NiceGUI ready to go on http://127.0.0.1:8000
[pywebview] WebView2 initialization failed with exception:
 Unable to load DLL 'WebView2Loader.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateCoreWebView2EnvironmentWithOptions(String browserExecutableFolder, String userDataFolder, ICoreWebView2EnvironmentOptions options, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler environment_created_handler)
   at Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__25.MoveNext()   
@rodja
Copy link
Member

rodja commented Mar 21, 2023

Thanks for reporting this issue. Does it only happen with the specific example of https://nicegui.io/#styling? The error looks so fundamental that I assume it's not working for all the examples. We use https://github.com/r0x0r/pywebview for opening a window with a webview. It looks like the issue originates there. Please try their getting started example (without NiceGUI being involved):

import webview
webview.create_window('Hello world', 'https://pywebview.flowrl.com/')
webview.start()

I've looked into their repo for similar issues but could only find r0x0r/pywebview#868 (comment). If the error is also reproducable with the non-NiceGUI example I suggest you open an issue at https://github.com/r0x0r/pywebview/issues.

@falkoschindler falkoschindler added the question Further information is requested label Mar 21, 2023
@Skjolbir
Copy link
Author

https://stackoverflow.com/a/74107882
Unrelated to nicegui technically, but for anyone with this issue, the answer above fixed it for me.

Apparently the Microsoft.Web.WebView2.Core.dll in the pip installed packages directory of webview (here: c:/Users/<your_user>/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0/LocalCache/local-packages/Python310/site-packages/webview/lib) cannot find the respective WebView2Loader.dll in the arch subfolders x64 or x86 in this very directory
Find out the arch of your Microsoft WebView2 Runtime (most likely x64) and just copy the dll from the respective subdirectory one up.

@rodja rodja removed the question Further information is requested label Mar 23, 2023
@rodja
Copy link
Member

rodja commented Mar 23, 2023

Great you found a solution @Skjolbir. I still wonder how that could happen and if more users are experiencing this issue. I think it would be ideal if you open an issue over at https://github.com/pyinstaller/pyinstaller/issues and help the community to find the root cause of it. Linking this issue would also be good for PyInstaller to track the urgency. I'll close this issue here. But feel free to add comments if you have new informations.

@rodja rodja closed this as completed Mar 23, 2023
@Skjolbir
Copy link
Author

I have raised the issue over there @rodja
For a suggestion on the nicegui end, I did find that changing the pywebview.start function away from WebKit renderer also fixed the issue. If we could set the pywebview renderer with an argument for ui.run(), and pass that along to webview.start(gui=arg), that would expand the options away from the sole dependency on WebKit from nicegui.

@rodja
Copy link
Member

rodja commented Mar 24, 2023

Thanks @Skjolbir. Could you provide the link to the issue. I could not find it. Your suggestion to make the renderer configurable is very appealing. Maybe we need to think about a way to arbitrary parameters to webview.start(...). Maybe a tuple webview_args?

@Skjolbir
Copy link
Author

My apologies, I misread your suggestion and had raised the issue with pywebview, which you can follow here:
r0x0r/pywebview#1078

I think a tuple with webview_args sounds like a good idea.

@rodja rodja changed the title Error when trying to run the example found at https://nicegui.io/#styling, with native=True Dll not found error when opening native window Mar 27, 2023
@rodja
Copy link
Member

rodja commented Mar 27, 2023

I just created #640 to continue discussion about improved webview configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants