Python autocompletion problem in Komodo 10

Hello I am having a problem with the autocompletion in python. I manage to import the modules however it does not suggest me all the possible modules inside the imported module. For instance:

Import numpy as np np.arra ....

Nothing is suggested. is like array does not exist.
I have my numpy library because it works with other IDE’s such eclipse

can you please help me?

Are you saying it works for some things but not for others? If so, could you share one such library for which you cannot get certain autocompletions?

Hi Nathanr

Thank you for your reply. With my local modules it does not have a problem. However, with the python modules komodo is having problems to autocomplet and give suggestions to very basic functions. For instance:

import numpy as np np.array(..) # no suggestion or completion
After I type the np and put the dot, a suggestion list should appear(sometimes it does and sometimes it does not). When it does, the array function is not mentioned. In addition, when I type array is not recognised. The array is just an example, many basic functions of np and other modules are not suggested.
import matplotlib.pyplot as plt plt.plot() # no suggestion or completion
and so on with other python modules. Under my settings -> languages I have specified the path to my python usr/bin/python and also to my local installations ~/.local/lib/python2.7

extra Information:
I am using Ubuntu 14.04.4 LTS and my komodo is installed locally because I don’t have sudo rights

Thank you in advance for your help

@mitchell looking at those libs, there seems to be a lot of magic going on for stuff like numpy.array and others. I’m guessing codeintel is choking on those. Can you investigate and see if it’s feasible to address this?

Our code intelligence will not pick up C functions in Python libraries. We only process functions defined in Python. You’ll have to create a catalog for Numpy and other C extensions if you want complete code intelligence.

I should clarify. Numpy is outside Python’s standard library (we provide codeintel for builtins and the standard library), and it’s primarily a C extension. That combination means we will not be able to provide good code intelligence for it. The same goes for matplotlib and other similar C extension libraries.

Dear Mitchell

Thank you for your reply. Do you have any suggestion to fix this. I rely a lot in the autocompletions and arguments suggestions as they allow me not to go an look in the web or other IDEs for info. So far I have to open my eclipse to look for suggestion of functions I forgot.

Thank you in advance for your help,

Hi @FelipeGM, sadly, other than creating a catalog to supply the completions for non-standard Python libraries, there is no “fix” :frowning: We have example catalogs you can look at in your Komodo’s “lib/mozilla/python/komodo/codeintel2/catalogs/” folder. They might aid you in creating one for Numpy and friends.


Actually, i noticed that autocompletion does not work for all the modules installed in the directory ‘Lib\site-packages’.
However, it works for modules in ‘Lib’.
In the configuration menu, I tried to add this as another import directory. But it does not work either.

The directory ‘Lib\site-packages’ contains packages I have installed myself : (sqlalchemy, jedi, pyflakes, etc…)
I sounds like autocomplete only support the standard library (‘Lib’)…

While Pandas, Numpy use C extensions, I guess not all them use those kind of extensions…

Can you help me on this, please?

Hi, I created a very simple project with the following directory structure:

    \ contains:

def baz():
  pass contains:

def qux():

When I added the lib/ directory to the project’s codeintel preferences, I can do the following in

from bar import |

and get the baz method autocompletion. This shows that lib/ is recognized by codeintel.

When I try:

from baz import |

I get nothing. I need to add the lib/site-packages/ directory to the project’s codeintel preferences too before I get the qux method completion.

The conclusion is that you also need to add your site-packages/ to codeintel’s path, much like you would to the PYTHONPATH in order to run your app.

Thanks for your attention.
Glad you made it work. I really wish do make it work to!:slight_smile:

Well, in the config menu (version 9.3.2), the sub-menu ‘codeintelligence’ is only available on the main preference menu and things related to languages is the ‘APPI Catalog’.

The project preference things related to python are exactly the same I did set up in the main preference : PYTHONPATH + ‘Additionnal Python 3 import directories’…

Thanks for your help!

Given your screenshot it appears you are adding site-packages/ properly. Is your sourcefile also identified as “Python3” in Komodo? Or is it “Python”? If the latter, you’ll either need to change to Python3 or add your site-packages/ to Languages > Python > Additional Python Import Directories.

Mitchell! Thanks, it works with your last tip : associating the file with python3.
However, autocomplete does not always found all the objects available in the lib package (some tests made with sqlalchemy).

Then, I have been curious to remove the ‘site-packages’ directory from the ‘additionnal python3 import directories’ and also from the PYTHONPATH… Restarted Komodo… and completion still works!
Kind of caching objects metada in the current packages? Should test after installing another lib.

Actually, in the codeintel preference, there’s a parameter about code scanning depth. Could it be, than, if the package is in a subdirectory and scan depth is set, then you do not need to add it to looking paths list?

Even if you remove directories from the “additional import directories” box, codeintel still has them cached, as you have noted. That is why you’re still seeing completions. Any new changes to that directory will likely not be picked up.

I’m not completely sure how the scan depth works. It might be language-specific (e.g. for languages like JavaScript and PHP that have no defined PYTHONPATH-like variable, but load all files into a global namespace), and may explain why Python doesn’t utilize it.

Thanks a lot for your support, Mitchell.

You’re welcome :slight_smile: