When writing Python code using compiled extensions (the OpenCV Python bindings, for example), PyCharm doesn't seem to be aware of their availability. The imports are marked with a grey underline, saying "unresolved reference" as a tooltip, and autocomplete doesn't work, either. (Except for the function names already used in the code.)
This isn't caused by wrong module paths, the code runs without error when started. Also, after I import the modules in a Python shell, autocomplete starts working as expected.
Is there a solution for that or is this an architectural limitation for compiled extensions? Are there any other IDEs that manage to cope with this problem?
Go to Settings / Preferences | Editor | General | Postfix Completion and select the Enable postfix completion checkbox.
(In Python Shell window, you can use TAB key besides the key combination of 'CTRL' and 'space' to invoke the built-in auto-completion feature.) Alternatively, you can choose the "Show Completions" in the main Edit menu to achieve the same as well.
Go to File > Settings (or Ctrl + Alt + S ) > [IDE Settings] > Editor > Code Completion. The "Autopopup code completion" setting will determine if the popup opens automatically. Below it, the "Insert selected variant by typing dot, space, etc." is likely the setting you want to turn off.
Intelligent code completion is a context-aware code completion feature in some programming environments that speeds up the process of coding applications by reducing typos and other common mistakes.
The imports are marked with a grey underline, saying "unresolved reference" as a tooltip
This most probably means that PyCharm can't see the module you import. In editing mode, PyCharm relies on availability of Python sources of imported modules. If a module is not written in Python but is a C extension module, PyCharm generates a 'skeleton' that contains function prototypes, and uses it for completion.
In shell mode, PyCharm uses live imported objects for completion, with slightly different results.
Make sure that your OpenCV installation is visible for the Python interpreter you chose for the project (File / Settings / Python interpreter). If the interpreter is correct, try removing and re-adding it (this is time-consuming a bit, sorry).
If nothing helps, file a bug.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With