The only thing I can get python omnicomplete to work with are system modules. I get nothing for help with modules in my site-packages or modules that I'm currently working on.
6 Answers
Once I generated ctags for one of my site-packages, it started working for that package -- so I'm guessing that the omnicomplete function depends on ctags for non-sys modules.
EDIT: Not true at all.
Here's the problem -- poor testing on my part -- omnicomplete WAS working for parts of my project, just not most of it.
The issue was that I'm working on a django project, and in order to import django.db, you need to have an environment variable set. Since I couldn't import django.db, any class that inherited from django.db, or any module that imported a class that inherited from django.db wouldn't complete.

- 1,173
- 2
- 18
- 28
-
I had this same problem except with app engine libraries, not django... thanks for helping me figure it out – gravitation Sep 24 '09 at 04:09
-
1Had this problem a few more times now, the first thing I always do is try to import the module in the vanilla interpreter, that always seems to show where the error is. If you are using django or app engine or whaterver a lot of times they do imports in a different order than the interpreter would which can cause problems. – gravitation Sep 27 '09 at 21:33
Trouble-shooting tip: verify that the module you are trying to omni-complete can be imported by VIM. I had some syntactically correct Python that VIM didn't like:
:python import {module-name}
Traceback (most recent call last):
File "<string>", line 1, in ?
File "modulename/__init__.py", line 9
class empty_paranthesis():
^
SyntaxError: invalid syntax
Case-in-point, removing the parenthesis from my class definition allowed VIM to import the module, and subsequently OmniComplete on that module started to work.

- 8,373
- 3
- 45
- 37
Just ran across this on Python reddit tonight: PySmell. Looks like what you're looking for.
PySmell is a python IDE completion helper.
It tries to statically analyze Python source code, without executing it, and generates information about a project’s structure that IDE tools can use.

- 1
- 1

- 2,982
- 2
- 26
- 43
I get completion for my own modules in my PYTHONPATH or site-packages. I'm not sure what version of the pythoncomplete.vim script you're using, but you may want to make sure it's the latest.
EDIT: Here's some examples of what I'm seeing on my system...
This file (mymodule.py), I puth in a directory in PYTHONPATH, and then in site-packages. Both times I was able to get the screenshot below.
myvar = 'test'
def myfunction(foo='test'):
pass
class MyClass(object):
pass

- 743
- 6
- 18

- 26,392
- 13
- 55
- 78
-
I just downloaded the most recent version -- no luck! How are you enabling it? Are you using CTAGs as well? – andrew Oct 14 '08 at 21:40
-
how are you testing it? try just putting something like "import sys" and then do "sys.
– Jeremy Cantrell Oct 16 '08 at 14:09" -
As I said above, system modules omnicomplete just fine. It's the modules in my site-packages that I'm not getting completion for. – andrew Oct 16 '08 at 15:22
-
yes, i understand. i'm just wondering how you're testing it. all of my personal modules, along with site-packages work. – Jeremy Cantrell Oct 16 '08 at 17:16
-
Ah. Yes. Sys modules _do_ work. Do you have CTAGs built for your site packages? What platform are you on? – andrew Oct 17 '08 at 03:47
-
I'm on Linux (Ubuntu 8.04). I have ctags, but i don't use them for anything but the taglist plugin. – Jeremy Cantrell Oct 17 '08 at 12:14
-
-
While it's important to note that you must properly set your PYTHONPATH
environmental variable, per the the previous answer, there is a notable bug in Vim which prevents omnicompletion from working when an import fails. As of Vim 7.2.79, this bug hasn't been fixed.

- 38,661
- 28
- 100
- 128
I think your after the pydiction script. It lets you add your own stuff and site-packages to omni complete.
While your at it, add the following to your python.vim file...
set iskeyword+=.
This will let you auto-complete package functions e.g. if you enter...
os.path.
and then [CTRL][N], you'll get a list of the functions for os.path.

- 4,128
- 3
- 32
- 37