Autocomplete in PyCharm for Python compiled extensions Autocomplete in PyCharm for Python compiled extensions python python

Autocomplete in PyCharm for Python compiled extensions


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.


I have noticed a difference in pycharm behavior depending on the way to import.using:

import cv2

the auto completion doesn't work,

while with:

from cv2 import cv2

auto completion works


I had to hardlink the binary into the folder lib-dynload of my interpreter.

$ cd /usr/lib/python3.7/lib-dynload$ sudo ln /usr/local/lib/python3.7/dist-packages/cv2/python-3.7/cv2.cpython-37m-x86_64-linux-gnu.so cv2.cpython-37m-x86_64-linux-gnu.so

The paths may vary in your environment. I didn't test it on OSX or Windows, but it may work there too. The lib-dynload folder is here:Project Structure