wxDemo Html2 possible bug

Running Ubuntu 20.04, Python 3.8.2. wxPython 4.1.0 compiled with Pypi.

When I launch the demo and try to load the HTML2 page I get the error attached, but when I run the initials imports in a command line all goes fine, so the html2 module was compiled with no issues.

Can you take a look? Let me know…error error2

What does ‘compiled with Pypi’ mean? It sounds like the wxPython version you have installed does not have WebView support, most likely due to missing WebKit development libraries when it was compiled.

On Ubuntu 20.04, the relevant development library package would be libwebkit2gtk-4.0-dev.

That means I installed and compiled wxPython using pip and not from the official repos…

Yes it have, I said that when I wrote about initials imports:
import wx
import wx.html2

pass with zero errors… this bug happens often in previous Ubuntu versions.

I just installed it but the bug is still there… or do I need to compile/install again wxPython with pip?

You have to recompile.

1 Like

Done!! but the same error, I use this command:

pip3 install -U --force-reinstall wxPython

I am not sure, but perhaps something got cached? It will need to recompile wxWidgets, so if you didn’t see that happening, then it didn’t work. If you are using a venv, then I would just delete your venv and create a new one.

In previous versions with the same bug the error shows when:

import wx.html2

line was executed, this time it have no issues there, I just run the file from console:

mario@mario-pc:~/Programas/wxPython-demo-4.1.0/demo$ python3 HTML2_WebView.py 
Python 3.8.2 (default, Apr 27 2020, 15:53:34) 
[GCC 9.3.0]
wx.version: 4.1.0 gtk3 (phoenix) wxWidgets 3.1.4
Traceback (most recent call last):
  File "/home/mario/Programas/wxPython-demo-4.1.0/demo/run.py", line 80, in OnInit
    win = self.demoModule.runTest(frame, frame, Log())
  File "./HTML2_WebView.py", line 142, in runTest
    win = TestPanel(nb, log)
  File "./HTML2_WebView.py", line 23, in __init__
    self.wv = webview.WebView.New(self)
OnInit returned false, exiting...

Yeah, Robin has implemented wrappers so that when certain optional components (e.g., WebKit) are missing during the wxWidgets build, the wxPython build won’t fail. Now you’ll get that NotImplementedError exception.

Ok ok, so now how can I reinstall?

Are you using a virtual env? If so, I would just delete it and create a new one. Otherwise, I’m not sure where the wxWidgets build gets stored by pip. You would need to clear it out so wxPython will build it again.

1 Like

No, its for my main dev machine… so I need to clean pip cache and force install again… that will take sometime, I’ll post later the results when its done… thanks!

and yes! that works! thanks for all your help @swt2c :+1:t2:

For future reference you can get pre-built wheels for Ubuntu 20.04 here, and for building it yourself you can see the list of needed dev packages in this Dockerfile script.

1 Like

Amazing! thanks!!

Also, on Ubuntu 20.04, you can get wxPython with apt-get as well, although it is 4.0.x and not 4.1.