I cannot get pyqt5 to run under anaconda python. The following is an error message I get when I run a script shown below:
Traceback (most recent call last
File [full path to the python script], line 9, in <module>
from PyQt5.QtCore import QT_VERSION_STR
ImportError: DLL load failed while importing QtCore: The specified module could not be found.
Here's the script that produced the error shown above:
import sys
print("Python version: " + str(sys.version))
print("Version info.: " + str(sys.version_info))
print("sys.hexversion: " + str(sys.hexversion))
from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.pyqtconfig import Configuration
print("Qt version:", QT_VERSION_STR)
cfg = Configuration()
print("SIP version:", cfg.sip_version_str)
print("PyQt version:", cfg.pyqt_version_str)
I made the following attempts to fix the problem:
Here's my Python and PyQT5 installation info:
But I still cannot run pyqt, because of the error shown at the top of this posting.
Any suggestions would be much appreciated.
I had a similar problem with PyQt - after upgrading to spyder 5.2.2 neither anaconda nor spyder would open at all - no splash screen etc or anything - it didn't even try to start the programs. Trying to start from the prompt, "anaconda-navigator" and "sypder" both returned:
(base) C:\Users\Geography Chair>spyder
Traceback (most recent call last):
File "C:\Users\Geography Chair\anaconda3\Scripts\spyder-script.py", line 10, in <module>
sys.exit(main())
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\spyder\app\start.py", line 233, in main
from spyder.app import mainwindow
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\spyder\app\mainwindow.py", line 41, in <module>
requirements.check_qt()
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\spyder\requirements.py", line 44, in check_qt
import qtpy
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\qtpy\__init__.py", line 188, in <module>
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
SystemError: initialization of QtCore failed without raising an exception
(base) C:\Users\Geography Chair>anaconda-navigator
Traceback (most recent call last):
File "C:\Users\Geography Chair\anaconda3\Scripts\anaconda-navigator-script.py", line 6, in <module>
from anaconda_navigator.app.main import main
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\anaconda_navigator\app\main.py", line 19, in <module>
from anaconda_navigator.app.start import start_app
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\anaconda_navigator\app\start.py", line 15, in <module>
from qtpy.QtCore import QCoreApplication, QEvent, QObject, Qt # pylint: disable=no-name-in-module
File "C:\Users\Geography Chair\anaconda3\lib\site-packages\qtpy\__init__.py", line 188, in <module>
from PyQt5.QtCore import PYQT_VERSION_STR as PYQT_VERSION # analysis:ignore
SystemError: initialization of QtCore failed without raising an exception
After a fair bit of messing around (conda install -c anaconda pyqt, conda install -c conda-forge pyqt, installs with specific versions...) I finally tried just updating pyqt (conda update pyqt). It worked. This is what it returned, if it helps anyone:
The following packages will be downloaded:
package | build
---------------------------|-----------------
pyqt-5.9.2 | py38hd77b12b_6 3.3 MB
sip-4.19.13 | py38hd77b12b_0 261 KB
------------------------------------------------------------
Total: 3.6 MB
The following packages will be REMOVED:
ply-3.11-py38_0
python_abi-3.8-2_cp38
The following packages will be UPDATED:
ca-certificates conda-forge::ca-certificates-2022.9.2~ --> pkgs/main::ca-certificates-2022.10.11-haa95532_0 None
pyqt anaconda::pyqt-5.9.2-py38ha925a31_4 --> pkgs/main::pyqt-5.9.2-py38hd77b12b_6 None
The following packages will be SUPERSEDED by a higher-priority channel:
certifi conda-forge/noarch::certifi-2022.9.24~ --> pkgs/main/win-64::certifi-2022.9.24-py38haa95532_0 None
conda conda-forge::conda-22.9.0-py38haa244f~ --> pkgs/main::conda-22.9.0-py38haa95532_0 None
openssl conda-forge::openssl-1.1.1q-h8ffe710_0 --> pkgs/main::openssl-1.1.1q-h2bbff1b_0 None
The following packages will be DOWNGRADED:
sip 6.6.2-py38hd77b12b_0 --> 4.19.13-py38hd77b12b_0 None