Can't start spyder because of PyQt5.QtWebKitWidgets - python

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:
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.

I swapped Pyqt5 version from 5.12 to 5.11.2 with:
py -m pip install pyqt5==5.11.2
And now it works...

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
and then Spyder launched perfectly

Related

Unable to launch Spyder after installation of PyQt5

On installation of PyQt5 i'm unable to launch Spyder on Windows. When i tried to launch through the conda prompt, i get the following error,
File "C:\Users\sarshetty\Anaconda3\lib\site-packages\qtpy\__init__.py", line 132, in <module>
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
RuntimeError: the sip module implements API v12.0 to v12.7 but the PyQt5.QtCore module requires API v12.8
I see the following for my sip and PyQt in the python terminal.
>>> import sip
>>> sip.SIP_VERSION_STR
'4.19.8'
>>> import PyQt5
>>> import PyQt5.Qt
>>> import PyQt5.QtCore
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: the sip module implements API v12.0 to v12.7 but the PyQt5.QtCore module requires API v12.8
I tried upgrading my sip, however that has not helped. Can anyone tell me what is happening and how i can resolve this.
I'm only guessing here but I think the error is referring to PyQt5-sip since the newest release is version 12.8.0
https://pypi.org/project/PyQt5-sip/
(Spyder maintainer here) Anaconda comes with its own version of PyQt5, so you don't need to install it by running pip install pyqt5 (which seems you did).
By doing that, you basically broke Anaconda and now you have to remove and reinstall it, sorry.
This fixed the issue for me
Uninstall the installed PyQt5 library with pip
pip3 uninstall pyqt5
Install PyQt5 with conda
conda install -c anaconda pyqt
Uninstall pyqt5(pip uninstall pyqt5) and then reinstall it version 5.11.3(pip install pyqt5==5.11.3)
After installing the new version it'll show an error msg but it will work anyways.
This has worked for me and my colleges.

No module named 'PyQt5.sip'

when I tried upgrading my PyQt version to 5.14.0 and later landed up importing the packages as:
from PyQt5 import QtGui, QtWidgets, QtCore
it throws an error:
runfile('C:/Users/Farhan Hyder .LAPTOP-R0TGSS2M/Desktop/BREATHE IN/Pred_WindowUI.py', wdir='C:/Users/Farhan Hyder .LAPTOP-R0TGSS2M/Desktop/BREATHE IN')
Traceback (most recent call last):
File "C:\Users\Farhan Hyder .LAPTOP-R0TGSS2M\Desktop\BREATHE IN\Pred_WindowUI.py", line 9, in <module>
from PyQt5 import QtGui, QtWidgets, QtCore
ModuleNotFoundError: No module named 'PyQt5.sip'
I also tried re-installing the libraries, but, unfortunately it didn't serve my purpose.
As per eyllanesc's comment, try updating pip:
python -m pip install --upgrade pip
Then try reinstalling pyqt5:
python -m pip install --upgrade pyqt5
It worked for me (though I actually used pip install --use-feature=2020-resolver pyqt5 for the new resolver).

Spyder does not open from anaconda

Recently, I had to reinstall anaconda on a new computer.
I downloaded the latest version from anaconda's website, and installed it just as I did before.
Now, when I open anaconda interface and try to run Spyder.exe, I get this message:
Traceback (most recent call last):
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-packages\qtpy\QtWebEngineWidgets.py", line 22, in
from PyQt5.QtWebEngineWidgets import QWebEnginePage
ImportError: DLL load failed: The specified procedure could not be found.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\Scripts\spyder-script.py", line
10, in
sys.exit(main())
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\spyder\app\start.py", line 186, in main
from spyder.app import mainwindow
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\spyder\app\mainwindow.py", line 90, in
from qtpy import QtWebEngineWidgets # analysis:ignore
File "C:\Users\aabramzonx0108132\AppData\Local\Continuum\anaconda3\lib\site-
packages\qtpy\QtWebEngineWidgets.py", line 26, in
from PyQt5.QtWebKitWidgets import QWebPage as QWebEnginePage
ModuleNotFoundError: No module named 'PyQt5.QtWebKitWidgets'
Could it be that I installed something wrong?
This has to do with PyQt5 module. To fix this issue try removing PyQt5
pip uninstall PyQt5
If that does not work try to reinstall it using
conda install -f qt=5 pyqt=5
Similar post here: 54869374
Anaconda 2020.07, Linux, x84_64
I do not know why, but installing
pip install pyqtwebengine
fixed spyder, which was part of the Anaconda installation.
Details:
This was tested on a fresh fedora-33 virtual machine with Anaconda version Anaconda3-2020.07-Linux-x86_64. pyqtwebengine was not installed before. Trying to uninstall it, gave a WARNING: Skipping pyqtwebengine as it is not installed.

PyQt5.QtWidgets module not found when pyqt is installed with Anaconda

I can import PyQt5 but I cannot import from PyQt5.QtWidgets when I install pyqt in a conda environment.
I've tried uninstalling and reinstalling with conda and that did not solve the problem.
If I install with pip in a regular virtual environment instead of with Anaconda then it works.
This is the code:
from PyQt5.QtWidgets import *
This is the error:
$ python main.py
Traceback (most recent call last):
File "main.py", line 1, in <module>
from PyQt5.QtWidgets import *
ModuleNotFoundError: No module named 'PyQt5.QtWidgets'
Turns out it was a path problem. I had installed Homebrew after Anaconda and /usr/local/bin was in front of $HOME/anaconda3/bin in $PATH, so Homebrew Python was being called instead of Anaconda Python.

I think jupyter-qtconsole is broken because I am running os x 10.10.5. How to fix without update?

Quick note: I had trouble with formulating my question. I do not know very much about jupyter-qtconsole, so I am not very sure what issue I am actually facing.
I am on mac book with os x 10.10.5 running pyenv virtual environments. A typical fresh virtual environment gets the following installed:
numpy
scipy
matplotlib
jupyter
qtconsole
pyqt5
sip (Recent addition)
jupyter_qtconsole_colorschemes
To bring up the console from the command line -> jupyter qtconsole with alias jqt
Today I went through this process and came upon an error. Note, my other virtual environments still work great.
Below is the error that I have found which is reproducible:
Cloud-Control:codingProjects KJSwanson$ cd 704
pyenv-virtualenv: deactivate 3.6.0/envs/test2
pyenv-virtualenv: activate 704
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(704)
Cloud-Control:704 KJSwanson$ jqt
Traceback (most recent call last):
File "/Users/KJSwanson/.pyenv/versions/704/bin/jupyter-qtconsole", line 7, in <module>
from qtconsole.qtconsoleapp import main
File "/Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/qtconsole/qtconsoleapp.py", line 60, in <module>
from qtconsole.qt import QtCore, QtGui
File "/Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/qtconsole/qt.py", line 23, in <module>
QtCore, QtGui, QtSvg, QT_API = load_qt(api_opts)
File "/Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/qtconsole/qt_loaders.py", line 365, in load_qt
result = loaders[api]()
File "/Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/qtconsole/qt_loaders.py", line 272, in import_pyqt5
from PyQt5 import QtCore, QtSvg, QtWidgets, QtGui, QtPrintSupport
ImportError: dlopen(/Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/PyQt5/QtCore.so, 2): Symbol not found: __os_log_default
Referenced from: /Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore (which was built for Mac OS X 10.11)
Expected in: /usr/lib/libSystem.B.dylib
in /Users/KJSwanson/.pyenv/versions/3.6.4/envs/704/lib/python3.6/site-packages/PyQt5/Qt/lib/QtCore.framework/Versions/5/QtCore
-> (which was built for Mac OS X 10.11)
1) Since my machine OS version is 10.10.5 is this in fact why I am having issues with jupyter qtconsole? (Some update to the module jupyter-qtconsole that conflicts?)
2) If this is not the reason, any suggestions on what the problem might be?
Here is the deal.
PyQt5 was the issue. The latest versions seems to require os x 10.11.x.
My solution was to uninstall PyQt5 and install the version, v=5.9.2, which is the version that works in a different virtual environment.

Categories