Ahmad Taha
Ahmad Taha

Reputation: 2015

PyQt5: The DLL load failed: the specified module could not be found

I recently installed the PyQt5 module setup for 32-Bit computers on Windows. But when I am trying to run their examples none of then would run. All of the examples provided were having the similar type of error as in the following image. And when I tried to import PyQt5 in the Python shell it just imported correctly.

Enter image description here

I think this shows PyQt is installed successfully.

But when i try to run the examples it shows like:

enter image description here

This is of one example and other examples have different 'no founds'

Facts - Running Windows 7, PyQt5 latest version, Python 3.5, Installed PyQt5 from original site with setup

I know there are several questions of such type, but none helped me because most of them were for Linux.

Upvotes: 10

Views: 33421

Answers (4)

Ed Randall
Ed Randall

Reputation: 7570

I experienced similar difficulties trying to install PyQt5 into an existing Python3.6 installation on Windows10 at C:\apps\Python36

  1. Don't install the download from https://www.riverbankcomputing.com/software/pyqt/download5 and if you have already installed it, uninstall using Windows Control Panel>Programs>Uninstall

  2. Open a new CMD prompt and ensure your PATH is set to include Python and Scripts

PATH=C:\apps\Python36;C:\apps\Python36\Scripts;%PATH%

  1. In the CMD shell, install PyQt5 using pip: pip install PyQt5. Afterwards check the installed packages:
     C:\>pip list
     Package    Version
     ---------- -------
     pip        10.0.1
     PyQt5      5.11.2
     PyQt5-sip  4.19.12
     setuptools 28.8.0
  1. There is a 'Hello World' program at https://www.tutorialspoint.com/pyqt/pyqt_hello_world.htm but it results in many errors like: AttributeError: module 'PyQt5.QtGui' has no attribute 'QApplication' due to PyQt4/5 changes. Try this instead:
     import sys
     from PyQt5 import QtWidgets

     def window():
        app = QtWidgets.QApplication(sys.argv)
        w = QtWidgets.QWidget()
        b = QtWidgets.QLabel(w)
        b.setText("Hello World!")
        w.setGeometry(100,100,200,50)
        b.move(50,20)
        w.setWindowTitle("PyQt")
        w.show()
        sys.exit(app.exec_())

     if __name__ == '__main__':
        window()
  1. For further details of changes between PyQt4 and PyQt5 see http://pyqt.sourceforge.net/Docs/PyQt5/pyqt4_differences.html

Upvotes: 1

Siva Manasan
Siva Manasan

Reputation: 123

Plese always make sure you are downloading the correct version of PyQt which is compatible with the python version you have, Curren PqQt only supports up to python 3.5.So you may need to install python 3.5 first and then follow the installation of PyQt.Hope it helps!

Upvotes: 1

ru13r
ru13r

Reputation: 194

I had a similar issue.

Everything worked when I completely uninstalled 32-bit version of Python, installed a 64-bit one, and reinstalled all the packages for amd64, including the PyQt5.

Upvotes: 1

Ahmad Taha
Ahmad Taha

Reputation: 2015

I got the answer to my own question.

When I tried to install it by setup, it did not ran properly. Then I uninstalled the setup and also ran the code in command line pip uninstall pyqt5 and then reinstalled by pip pip install pyqt5.

Then it perfectly ran, but by installing with pip it doesn't provide any examples so for that install the setup in any other directory and copy the examples in the PyQt5 folder. Done!

I think there may be some bug in the setup.

Upvotes: 13

Related Questions