0

I am aware that some solutions for this have been suggested in 1, 2, and 3. I tried almost all of them. I tried:

  • Running the pyuic5 using absolute paths for the file 4
  • Uninstalling and installing different versions of pyqt5 and pyqt5-tools 5, 6
  • I also tried copying the python3.dll from the python folder to the Scripts folder in the virtual environment 7, 8

None of these seemed to work, so I am trying to run PyQt5, I already have a .UI file and I would like to run it, but it keeps giving me the error. My machine is Windows 10

File ".\test.py", line 1, in <module> from PyQt5 import QtWidgets, uic
ImportError: DLL load failed: The specified module could not be found.

This is the test.py file:

from PyQt5 import QtWidgets, uic
import sys

app = QtWidgets.QApplication([])

win = uic.loadUi("User_Interface.ui") #specify the location of your .ui file 

win.show()

sys.exit(app.exec())

I execute it in a virtual environment that has Python 3.7.9 (this is what appears when i type python -V) with the command python test.py

The installed packages are the following (using the pip list command):

click         6.7
packaging     21.3
pip           20.1.1
ply           3.11
pyparsing     3.0.9
PyQt5         5.9
pyqt5-tools   5.9.2.1.3
python-dotenv 0.20.0
setuptools    47.1.0
sip           4.19.8
toml          0.10.2

This solution 9 suggests upgrading the C++ runtime environment to 2015-2019, but I already have that.

10

11

If any more information is needed, I'll be happy to provide them. Any help is more than appreciated.

If PyQt5 works properly on your machine, can you state the packages and versions you have installed, so I can recreate your virtual environment

Ahmet-Salman
  • 194
  • 8
  • What specific virtual environment are you using? Have you tried starting a python interpreter in the activated venv and executing `from PyQt5 import QtCore`? What errors, if any, does this produce? (PS: please make sure you always provide **the full tracback** from running **the actual code** shown in your question. The line number in your current example doesn't match up, which introduces an unnecessary element of doubt). – ekhumoro Jun 11 '22 at 12:37
  • Yes, I tried running the interpreter and typing ```from PyQt5 import QtCore``` and it gives the same error. The reason for the line mismatch is that there were some comments above the code, I'll fix the error message to reflect the true line number edit: Here is the error message from the interpreter: ```>>> from PyQt5 import QtWidgets Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: The specified module could not be found. ``` – Ahmet-Salman Jun 11 '22 at 13:20
  • Is Qt5Core.dll's path in PATH env variable? try running `where Qt5Core.dll` in cmd shell (not in python shell) after activating virtual environment – mugiseyebrows Jun 11 '22 at 21:44

0 Answers0