10

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ahmad Taha
  • 1,975
  • 2
  • 17
  • 27
  • I'm guessing you installed 32-bit pyqt binaries but you have a 64-bit OS and 64-bit python. Uninstall and reinstall 64-bit pyqt – Brendan Abel Apr 16 '16 at 17:40
  • The `import PyQ5` test is no good, because it only imports an empty namespace. You need to try `from PyQt5 import QtCore`. – ekhumoro Apr 16 '16 at 18:06
  • did You use the windows-installer of pyqt5 (contains QT5) or did you compile the source code, then You have to install QT5 first – a_manthey_67 Apr 16 '16 at 19:25
  • Yup i did all everything is Ok – Ahmad Taha Apr 17 '16 at 07:01
  • "The PyQt5 wheel includes the necessary parts of the LGPL version of Qt. There is no need to install Qt yourself." - ref. http://pyqt.sourceforge.net/Docs/PyQt5/installation.html – Ed Randall Jul 15 '18 at 07:31

4 Answers4

13

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Ahmad Taha
  • 1,975
  • 2
  • 17
  • 27
  • 3
    That's because the current PyQt setup is for Python 3.4, not 3.5. PyQt 5.6 will be compiled for Python 3.5 on Windows, and released as a PyPI wheel. `pip install pyqt5` currently installs the prerelease of that. – The Compiler Apr 17 '16 at 13:04
  • so whats the best proper way to install pyqt5,because this is not working at all ... i mean at all it is not working in python 3.5 or 3.6 win 32 version !!!!!!! Please help!!!! – kinsley kajiva Apr 28 '17 at 14:44
  • 4
    Still seems to be a problem with PyQt 5.9 and Python 3.5.2. :-( – Frank Smith Aug 07 '17 at 13:27
1

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ru13r
  • 194
  • 8
1

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!

Siva Manasan
  • 123
  • 4
  • 14
1

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
Ed Randall
  • 6,887
  • 2
  • 50
  • 45