Pycharm, PyQt5 and Python 2.7 - No code completion

I have:

  • Python 2.7 ( Anaconda x64 ) which works great
  • PyQt5 (installed using pip install python-qt5 )
  • PyCharm 4.04 Professional (recently updated from 3.4.1)
  • Small Qt Application

After a lot of hair pulling (since Riverbank does not contain the PyQt5 binary for Python 2.7, only for 3.3+), I got everything that works thanks to the pre-compiled binary packages of Marcus Otosson.

Qt is now installed and fully functional. Qt application works great!

But the application is not finished yet, and PyCharm will not complete code completion for PyQt modules. He won’t even know that there are any PyQt5 submodules (for example, Qwidgets): although they work very well, I still get a warning with the red squiggly "Unresolved Reference" .

How to fix it? I assume this is due to the inherent difficulties in creating skeletons for *.pyd . How it works? Can I manually generate code skeletons or import them from somewhere, are they generated correctly?

Uninstalling and reinstalling PyCharm did not help. It also did not reconfigure the interpreter to make the skeletal generator work again.

Please help before I go bald.

+7
python pyqt5 pycharm pyqt code-completion
source share
3 answers

I am using PyCharm4 (Edititon community) on Windows with PyQt4, autocomplete is fine. Since PyQt4 is actually a dynamic library that is dynamically loaded by the python interpreter (you can look in the PyQt4 folder, there are no python files there, except for some init .py files), autocompletion depends on the source code of PyQt4 itself, so when using pycharm some local cache is usually used -Pitton for the full. For my machine, a typical file looks like this: C: \ Users \ cui.PyCharm40 \ system \ python_stubs-762174762 \ PyQt4 \ QtCore \ QString.py

You can also try installing the PyQt document from Pycharm. File-> Settings-> Tools-> python external document-> PyQt

+1
source share

Can you find PyQt5 from your External Libraries project? If you install it through pip, you can see the library directly. After the library is transferred, it will complete the code for you.

0
source share

There was the same issue in PyCharm 2017.1.1. Do not do it

 import PyQt5.QtWidgets 

do

 from PyQt5 import QtWidgets 
0
source share

All Articles