Pydev Code Completion for bpy : .pypredef files + generation script

Hi fellow python coders,

I so wanted code completion when tinkering with blender python api that I took the plunge and repurposed - script used for the api docs generation - to generate .pypredef files for Pydev. So if it’s in the docs, code completion should be now available. usage:

./blender --background --python /path/to/

This will generate, alongside the script, a folder named pypredef_bpy_api_version.
This folder contains the necessary files to enable code completion for bpy, blf and mathultils modules within pydev.

How to:
In Eclipse:

  • Window > Preferences…
  • Preferences > Pydev > Interpreter-Python
  • Python Interpreters > Predefined > New…
  • Select Folder then Apply


  • bgl, aud and bge modules are not currently supported
  • code completion is not exhaustive, parts of the api are not documented. In doubt, check the online docs


obj = bpy.context.active_object
# code completion will also work for obj
obj = bpy.context.selected_objects[0]
# code completion doesn't work for obj.
# but you can assert the type of obj
assert isinstance(obj,bpy.types.object)
# and now code completion will work as expected for obj

The attached archive contains:

  • : script to generate the .pypredef files
  • a folder containing pre-generated .pypredef files for the python api corresponding to the 2.57b release

Happy coding,


Thanks a lot! I was already looking for a way to generate blender API stub classes to make autocomplete work in pyDev. You have saved quite some time for me with this. Currently I am testing what possible problems can be in this approach, and found something in my current script. Seems like there is a problem with altering existing types and autocomplete, for example:

import bpy

bpy.types.Scene.evil_global = '66'

In this case, whan typing last line “evil_global” is recognised and and even available in autocomplete. But after validating the file it is marked as error (since original Scene object has no such member). Any ideas about solution for that?

Anyway, you did a great job and this was another step towards normal workflow for developing blender extensions.

do you know if there’s something similar for notepad++ ?

ahaha I am thanks a lot ! :slight_smile:


i just ran the script on a fresh svn update
and i wonder why the first 2 lines in the def draw() compile
and the third line doesn’t …

import bpy

def draw():
    ms =
    me ="compiles")
    otherMe ="doesntCompile")
    Description    Resource    Path    Location    Type
Undefined variable from import: new    /blender_pydev/src    line 7    PyDev Problem

if __name__ == "__main__":

any explanations ?

i ran the script on a fresh svn update of the blender sourcecode
and it created the folder ‘pypredef_bpy_2_58_1_r37811’

and kind regards

this script causes error for me. do you have any idea?

c:\Graphics\Blender258>blender --background --python
Info: Config directory with “startup.blend” file not found.
found bundled python: c:\Graphics\BLENDE~3\2.57\python
Traceback (most recent call last):
File “<string>”, line 1, in <module>
File “<string>”, line 1054, in <module>
File “<string>”, line 1048, in main
File “<string>”, line 375, in rna2pypredef
File “<string>”, line 207, in pycontext2pypredef
File “c:\Graphics\BLENDE~3\2.57\python\lib\”, line 340, in _
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 126] The specified module could not be found

Blender quit

It is a perfect case of paralel development!
On march-april 2011 I adapted the same script for the same purpose! Mine is named It has been added and described in this free book:

Becasue I use Windows, I can explain atmuc and sc3sc3 their problems:

Original Campbell Barton’s script used a kind of hack to read the alternative context structures (this structure has a different fields in different windows - a thing that is impossible to match properly with PyDev autocompletion). It tries to use current executable (blender.exe) as an unnamed shared object (a dynamic link library) and read the context structures directly from the structures that are exposed as public part of this shared binary code. This hack does not work in Windows, unfortunately. In my version of the script I have just skipped creation of this small part. You will find it in the file that accompanies the book, and the book contains detailed description how to generate the *.pypredef files, along with easier debugging of Blender scripts…

@witold you saved my days with what you did :slight_smile: thanks…

This is wonderful! Thank you

If by some coincidence someone is still using this, I updated pypredef file for 2.80: (60.1 KB)

Pydev actually does not need anything if Blender is compiled as Python module and installed into Python folder, in fact it has the best working completion for Blender stuff. All the other ones I myself tried (VsCode, Pycharm etc) sucked to death.

Well I’m using this for PyCharm in conjunction with my script that fixes some things produced by running blender against file linked above and I’m more than happy for several years already.


I’m trying to setup an IDE using PyCharm and Blender 2.82… I don’t know what went wrong.

I cannot find a good instruction using google. I would appreciate anyone who could tell me what I need to do. :thinking: