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

Gives an error when executed:

Unbehandelte Ausnahme: System.NullReferenceException: Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.
   bei System.Windows.Forms.Control.get_CacheTextInternal()
   bei System.Windows.Forms.Control.get_Text()
   bei System.Windows.Forms.Control.set_Text(String value)
--- Ende der Stapel�berwachung vom vorhergehenden Ort, an dem die Ausnahme ausgel�st wurde ---
   bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   bei Python.Runtime.PythonException.ThrowLastAsClrException()
   bei Python.Runtime.Dispatcher.TrueDispatch(Object[] args)
   bei Python.Runtime.Dispatcher.Dispatch(Object[] args)
   bei __System_Threading_ThreadStartDispatcher.Invoke()
   bei System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   bei System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   bei System.Threading.ThreadHelper.ThreadStart()

The above problem is solved by installing pythonnet 3.0.0a2, but now it gives an error:

Traceback (most recent call last):
File "C:\Users\User\Documents\Visual Studio Code\Python Projects\webviewTest.py", line 3, in <module>
webview.start()
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\webview\__init__.py", line 122, in start
guilib = initialize(gui)
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\webview\guilib.py", line 101, in initialize
if not try_import(guis):
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\webview\guilib.py", line 62, in try_import
if import_func():
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\webview\guilib.py", line 52, in import_winforms
import webview.platforms.winforms as guilib
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\webview\platforms\winforms.py", line 31, in <module>
import clr
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\clr.py", line 6, in <module>
load()
File "C:\Users\User\AppData\Local\Programs\Python\Pytho n39\lib\site-packages\pythonnet\__init__.py", line 42, in load
func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"]
TypeError: 'Assembly' object is not subscriptable

Can you please tell me what can be done, how can I use pywebview?

Max Payne
  • 21
  • 2

1 Answers1

2

At the moment, for pywebview to work correctly, you need to use: pythonnet 3.0.0a2 and clr-loader 0.1.7:

pip install pythonnet==3.0.0a2
pip install clr-loader==0.1.7

Solution found here

Max Payne
  • 21
  • 2