Fixing Python PyQt5 ModuleNotFoundError: No module named ‘PyQt5.QtWebEngineWidgets’

Python PyQt5 ModuleNotFoundError: No module named ‘PyQt5.QtWebEngineWidgets’ is an error which occurs when you have a faulty PyQt5 installation.

Today I will be explaining why this error is taking place and how to solve it.

Exploring the Python PyQt5 ModuleNotFoundError: No module named ‘PyQt5.QtWebEngineWidgets’

This is an error which occurs when you have a faulty PyQt5 installation.

You should avoid mixing between different errors. The error message should look like the error message bellow.

                                                                       #
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'
                                                                       #

Bellow is a number of tested solutions that I have tried and worked for me.

Solution 1 : Downgrade pyqt5 or uninstall PyQtWebEngine and reinstall it again

The error occurs when you try installing PyQt5 using your package manager

                                                                       #
pip install PyQt5
                                                                       #

The first solution is Downgrade pyqt5, just install a version earlier than the version you are trying to install and see what happen.

For this example we used PyQt5==5.15.5 , choose your desired version.

                                                                       #
pip install PyQt5==5.15.5
                                                                       #

Another option is to uninstall PyQtWebEngine and reinstall it again.

For uninstall use this

                                                                       #
pip uninstall PyQtWebEngine
                                                                       #

Finally, use pip to install PyQtWebEngine

                                                                       #
pip install PyQtWebEngine
                                                                       #

I hope the error is gone by now, please try the method bellow if this method did not work.

Solution 2 : uninstall all the PyQt5 libraries Then install them again

Another great option you can try is to uninstall all the PyQt libraries Then install them again, you should remove these three libraries PyQt5, PyQt5-sip and PyQtWebEngine.

Try this command to remove all the packages related to PyQt5 at once.

                                                                       #
pip uninstall `pip freeze | grep PyQt5`
                                                                       #

If that does not work, then remove the packages the normal way

                                                                       #
pip uninstall PyQt5
# do the same for the other two packages : PyQt5-sip and PyQtWebEngine
                                                                       #

Now, you should install the libraries again, just use install instead of uninstall.

I hope the methods I provided have been helpful, I hope you solved the error already.

Summing-up : 

Guys, this has been my best attempt at helping you understand and solve this issue. I hope you found a solution which suits your needs.

Thank you for reading, keep coding and cheers. If you want to learn more about Python, please check out the Python Documentation : https://docs.python.org/3/