Pydev Doesn't Recognise Pyqt5
Solution 1:
I had the same problem. These steps worked for me.
- Set the environment variable: export QT_API=pyqt5 (or whatever as appropriate)
- 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
- Install python v3.6
- Install eclipse from eclipse.org
- In eclipse, click Help->Install New Software
- Click Add...
- Add in software source "http://www.PyDev.org/updates" to the available software sources
- Call it PyDev
- Click on PyDev checkbox
- Install it by clicking Next
- Download PyQt5
- Download SIP
- Install SIP first
- Install PyQt5
- Reconfigure eclipse to use PyQt5
- Click on Window→Preferences→PyDev→Interpreters→Python Interpreters
- Click on Advanced Auto-Config
- Rename interpreter to “python3.6”
- Click on Libraries tab
- Click on New Folder
- Add in “/usr/lib/x86_64-linux-gnu/qt5/plugins”
- Add in “/usr/lib/x86_64-linux-gnu/qt5/libexec”
- Add in “/usr/lib/x86_64-linux-gnu/qt5/bin”
- Click Apply
- Click Apply and Close
- Restart eclipse
- 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"