Skip to content Skip to sidebar Skip to footer

Pydev Doesn't Recognise Pyqt5

I am following a tutorial on pyqt, and got this code: import sys from PyQt5.QtCore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * class Example(QWidget): de

Solution 1:

I had the same problem. These steps worked for me.

  1. Set the environment variable: export QT_API=pyqt5 (or whatever as appropriate)
  2. restart eclipse so that picks up the new environment setting, and then add PyQt5 to the list of forced builtins for the interpreter (Window->preferences->pydev->interpreters->python interpreters) or look here http://www.pydev.org/manual_101_interpreter.html for more details.

The following SO question tipped me off to the presence of the variable: Setting up IPython Qtconsole with PyQt5. Before I set it, I as able to get some completion to work just by adding 'PyQt5' to the builtins, but it would not, for example, provide the full list of completions to something likefrom PyQt5.QtGui import, even though ipython stand-alone would. Further, the python console in pydev had the same problem and calling module_completion("from PyQt5.QtGui import Q") from Ipython.core.completerlib produced the same incomplete list. In the end, I guessed that since pydev was loading PyQt4 for the gui event loop (also configurable in the interpreter settings), there was a namespace conflict when it tried to introspect the Qt5 modules, causing it to bail out before it could build the full list of completions. Setting the environment variable causes pydev to load pyqt5 instead of the default pyqt4. I haven't checked, but it seems likely that set this way pydev will have problems completing pyqt4 references.

Solution 2:

For all those lonesome internet wanderers trying to figure out how to integrate eclipse, pydev, and pyqt5 on Linux, I bring you my method from start to finish.

Eclipse, PyQt5, and PyDev on Linux

  1. Install python v3.6
  2. Install eclipse from eclipse.org
  3. In eclipse, click Help->Install New Software
  4. Click Add...
  5. Add in software source "http://www.PyDev.org/updates" to the available software sources
  6. Call it PyDev
  7. Click on PyDev checkbox
  8. Install it by clicking Next
  9. Download PyQt5
  10. Download SIP
  11. Install SIP first
  12. Install PyQt5
  13. Reconfigure eclipse to use PyQt5
  14. Click on Window→Preferences→PyDev→Interpreters→Python Interpreters
  15. Click on Advanced Auto-Config
  16. Rename interpreter to “python3.6”
  17. Click on Libraries tab
  18. Click on New Folder
  19. Add in “/usr/lib/x86_64-linux-gnu/qt5/plugins”
  20. Add in “/usr/lib/x86_64-linux-gnu/qt5/libexec”
  21. Add in “/usr/lib/x86_64-linux-gnu/qt5/bin”
  22. Click Apply
  23. Click Apply and Close
  24. Restart eclipse
  25. Profit!

This will allow you to get the tab code completion in eclipse when developing pyqt5 applications.

Post a Comment for "Pydev Doesn't Recognise Pyqt5"