Reputation: 29
I installed these libraries:
>pip freeze | findstr pythonnet
pythonnet==3.0.0a2
>pip freeze | findstr clr-loader
clr-loader==0.1.7
>pip freeze | findstr pywebview
pywebview==3.6.3
And I created a test.py with this content: The code is:
import webview
webview.create_window('Hello world', 'https://pywebview.flowrl.com/')
webview.start()
I'm on Windows 10 and the result is a blank page: screen
Upvotes: 2
Views: 2511
Reputation: 21
same here. In short:
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.
How can that be found out?
Add try/except
block and add code for unsuccessful initialization of CoreWebView2
(args.InitializationException
) in edgechromium.py
in the webview package, edgechromium
is the default gui
of the webview:
def on_webview_ready(self, sender, args):
try:
logger.debug('### on_webview_ready')
logger.debug('---> '+str(args.InitializationException))
sender.CoreWebView2.NewWindowRequested += self.on_new_window_request
settings = sender.CoreWebView2.Settings
settings.AreDefaultContextMenusEnabled = _debug['mode']
settings.AreDefaultScriptDialogsEnabled = True
settings.AreDevToolsEnabled = _debug['mode']
settings.IsBuiltInErrorPageEnabled = True
settings.IsScriptEnabled = True
settings.IsWebMessageEnabled = True
settings.IsStatusBarEnabled = _debug['mode']
settings.IsZoomControlEnabled = True
if _user_agent:
settings.UserAgent = _user_agent
if self.html:
sender.CoreWebView2.NavigateToString(self.html)
logger.debug('-----------> '+str(sender.CoreWebView2))
except Exception as e:
logger.exception(str(e))
This throws the error (german), the arg name can be found here
[pywebview] ---> Die DLL "WebView2Loader.dll": Das angegebene Modul wurde nicht gefunden. (Ausnahme von HRESULT: 0x8007007E) kann nicht geladen werden.
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.CreateCoreWebView2EnvironmentWithOptions(String browserExecutableFolder, String userDataFolder, ICoreWebView2EnvironmentOptions options, ICoreWebView2CreateCoreWebView2EnvironmentCompletedHandler en
vironment_created_handler)
bei Microsoft.Web.WebView2.Core.CoreWebView2Environment.<CreateAsync>d__3.MoveNext()
--- Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde ---
bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
bei Microsoft.Web.WebView2.WinForms.WebView2.<InitCoreWebView2Async>d__13.MoveNext()
[pywebview] 'NoneType' object has no attribute 'NewWindowRequested'
Traceback (most recent call last):
File "C:\Users\<your_user>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\webview\platforms\edgechromium.py", line 153, in on_webview_ready
sender.CoreWebView2.NewWindowRequested += self.on_new_window_request
AttributeError: 'NoneType' object has no attribute 'NewWindowRequested'
Upvotes: 0