Why Isn't Pycharm's Autocomplete Working for Libraries I Install

Why isn't PyCharm's autocomplete working for libraries I install?

You've installed the 3rd-party library into a virtualenv, but PyCharm doesn't know about that by default. If nothing is specified, it will choose the system Python install as the interpreter. You need to go into the project settings and configure the interpreter to point at the virtualenv. PyCharm will then index the interpreter and allow you to autocomplete.

Project interpreter settings

The virtualenv may be auto-detected in the dropdown menu on the left. If it is not, click the gear to the right, click "Add local", and select /path/to/virtualenv/bin/python (or \Path\to\virtualenv\Scripts\python.exe on Windows).

Autocomplete for OpenCV-Python in Windows not working

The reason it's not working is because you're using a .pyd file, which is essentially the same as a compiled .dll. Autocomplete works by reading the source .py files, which are plain text. Try installing the OpenCV and Intel Math Kernel Library optimized NumPy packages from Christoph Gohlke's Python Extension Packages for Windows repository, which is frequently updated and a must-use resource for anyone who does any kind of scientific Python computing on Windows. Make sure you delete the cv2.pyd and numpy directories from site-packages first. These new packages will install the .py source files needed by the autocomplete engine in Sublime Text.


EDIT

OK, so I wrote the above because it worked well for a bunch of other packages. I'm a Python 3 guy, and I never installed OpenCV from Gohlke because it only has Python 2 bindings. After reading @CrazyCoder's comment below, I booted up Win7, and indeed he's absolutely correct (and I should have realized this before) - since OpenCV is written in C/C++, the only .py file included in the Gohlke package is cv.py, whose entire contents are as follows:

from cv2.cv import *

The rest is contained in cv2.pyd and a bunch of .dlls. The full OpenCV Windows distribution from opencv.org is a 291 MB download, which expands to 3 GB, and the few .py files in there are involved in building OpenCV, and aren't any good for autocomplete purposes. So, unfortunately, I don't know if there's a solution to your problem at the moment. Just keep the docs handy, and perhaps check out OpenCV Computer Vision with Python from Packt/O'Reilly, published in April 2013.

Why PyCharm not show autocomplete list

PyCharm doesn't know the type of im as the library has no type hints for Image.open(). So I decided to set local type hint like this:

your_image = Image.open(path_to_image) # type: Image.Image
your_image.now_shows_list = True

For complete reference look at JetBrains type hints documentation.

Robot Framework with Pycharm -- Autocomplete doesn't work

Try to set up your Library to robotframework-selenium2library == 1.8.0, then the issue will disappear.

If you have the last version it doesn't work for me.



Related Topics



Leave a reply



Submit