Sagneta
Sagneta

Reputation: 31

Python pywebview webview.start() System.NullReferenceException object reference not set at System.Windows.Forms.Control.get_CacheTextInternal()

I did the install like it is shown at https://pypi.org/project/pywebview/ and i use the example code

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

and here is the full error i get

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()

i tried debugging webview.start(). There it crashes at guilib.create_window(windows[0]) although windows[0] is not empty

Upvotes: 3

Views: 1680

Answers (1)

hgzhgb
hgzhgb

Reputation: 59

Had the same problem and could fix it by reducing the version of pythonnet to "3.0.0a2". Everything after that (up to this date / 13.07.2022) didn't work anymore. The following did the trick:

pip install pythonnet==3.0.0a2

Was tested with pywebview version 3.6.3 on windows 10

Upvotes: 5

Related Questions