Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't start spyder because of PyQt5.QtWebKitWidgets

I have a problem with spyder.

I just installed on this laptop Python 3.7 and Spyder, as I did on many others. However this time, it doesn't work.

I installed Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 23:09:28) [MSC v.1916 64 bit (AMD64)] on win32 with the installer. I changed the path to a custom path: C:\Python\Python37, I added the precompile library and I added the path to the environment. The laptop was rebooted at that point.

Then I updated pip:

py -3.7 -m pip install --upgrade pip

And then I installed spyder:

py -3.7 -m pip install spyder

I then try to launch spyder with the file:

C:\Python\Pythno37\Lib\site-packages\spyder\app\start.py

I get the error:

ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'

PyQt5 is installed with version 5.12.

No clue why it doesn't work...

EDIT: The full error message:

Error msg

It sugggest that the problem comes from qtpy. However, the corresponding file imports:

from . import PYQT5,PYSIDE2, PYQT4, PYSIDE, PythonQtError


# To test if we are using WebEngine or WebKit
WEBENGINE = True


if PYQT5:
    try:
        from PyQt5.QtWebEngineWidgets import QWebEnginePage
        from PyQt5.QtWebEngineWidgets import QWebEngineView
        from PyQt5.QtWebEngineWidgets import QWebEngineSettings
    except ImportError:
        from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
        from PyQt5.QtWebKitWidgets import QWebView as QWebEngineView
        from PyQt5.QtWebKit import QWebSettings as QWebEngineSettings
        WEBENGINE = False

The PyQt5.QtWebEngnieWidgets is correctly used.

like image 422
Mathieu Avatar asked Feb 25 '19 15:02

Mathieu


2 Answers

I swapped Pyqt5 version from 5.12 to 5.11.2 with:

py -m pip install pyqt5==5.11.2

And now it works...

like image 64
Mathieu Avatar answered Nov 06 '22 05:11

Mathieu


Three days ago I was playing around with Python, Mayavi and Jupyter Notebooks to create visualizations. This required to install PyQt5.

Due to constantly reaching memory errors, I've decided to test without using virtualenv's and installed the needed requirements on my local environment (which of course didn't solve).

After that, I was on my way to create visualizations using matplotlib and other Python libraries but can't launch Spyder from the Anaconda Navigator.

This is the error showing up, which is similar to yours

Traceback (most recent call last):
File "C:\Users\tiago\Anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in 
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebEngineWidgets'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\tiago\Anaconda3\Scripts\spyder-script.py", line 10, in 
sys.exit(main())
File "C:\Users\tiago\Anaconda3\lib\site-packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "C:\Users\tiago\Anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 90, in 
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\Users\tiago\Anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 26, in 
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'

The correct answer didn't work in my case.

This problem had to do with the PyQt5 installation. The way to fix it was to uninstall it

pip uninstall PyQt5

Solved after uninstalling PyQt5

and then Spyder launched perfectly

Spyder finally launched

like image 21
Tiago Martins Peres Avatar answered Nov 06 '22 06:11

Tiago Martins Peres