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

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.

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.

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.

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

Pyqt5 is installed but gives dll failed to load error on import?

So, I tried to install PyQt5(version 5.7.1) for my miniconda3(python version 3.5.1) with pip install PyQt5 and it shows up when I try conda list in console:
But no pyqt5 program is running and when I import something like:
from PyQt5.QtWidgets import QApplication
its gives an ImportError:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: The specified module could not be found.
How can I fix this? Do I have to install C++ and Qt lib for C++ for this to work?? Please Help!
I know it's an old question, i've found solution that worked for me, maybe it will be useful for somebody else.
conda list
should contain pyqt PyQt5 and qt. If any of it are not there, you need to install it - run:
conda install qt, for example.
I see in the question there is pyqt and PyQt5 installed, but is there qt?

pyqt5 cannot install with python 3.5

I installed python 3.5 then install pyqt5.5.1, when installing the binary file under win7, it showed warning that it's built under python3.4.I installed to the python35 directory anyway.I can open Assistant in start menu.But in python it's not working:
from PyQt5.QtCore import * Traceback (most recent call last): File "", line 1, in
from PyQt5.QtCore import * ImportError: DLL load failed
Use pip to install the Windows wheel file
The installer were based on 3.4. So you can't use it.
Download LINK
Command line guide: pip install name_of_file.whl
PS: install SIP in the same way.

Categories