1

I recently added jedi-vim to my plug-in arsenal. It works just fine for the standard modules, but is unable to find bpy and bmesh stuff.

So in the blender console I took the output of print(sys.path) and added it to a vimscript function in a .lvimrc file, like this:

function BpyPath()
    python sys.path.append('/home/john/src/blender-2.77-linux-glibcl211-x86_64/2.77/python/lib/python3.5')
    ...
endfunction

Now it works better. Typing bpy. gives me:

enter image description here

But typing bpy.context. still gives me: -- Omni completion (^O^N^P) Pattern not found

Versions:

  • Blender: 2.77a 64-bit linux
  • OS: Fedora 22
  • Python: 2.7.10
  • Vim: 7.4

I am not a very advanced python or vim user, so any help is appreciated.

Jair López
  • 650
  • 1
  • 5
  • 16
John
  • 530
  • 5
  • 19
  • What you wanted to be shown? – SibiCoder Jun 13 '16 at 11:58
  • @SibiCoder Functions and variables in bpy.context namespace – John Jun 13 '16 at 12:06
  • Can you give an example snippet with littel explanation of it and show me what you want? – SibiCoder Jun 13 '16 at 12:11
  • @SibiCoder I cant think of a way to better describe my problem other than: I want to use autocompletion in Vim when writing blender scripts. So I need help setting up jedi-vim. – John Jun 13 '16 at 12:55
  • You may have to set path. Tell me where your file resides, what you wanted to show as an example( function or variable), also, put the output of `:set path ` here. Also, add the path of the file here. – SibiCoder Jun 13 '16 at 13:49
  • @SibiCoder Running print(bpy.__file__) from blenders own python console gives the output: /home/john/src/blender-2.77a-linux-glibc211-x86_64/2.77/scripts/modules/bpy/__init__.py – John Jun 13 '16 at 14:03
  • Print the output of `:set path` execute in vim command line. – SibiCoder Jun 13 '16 at 14:04
  • path=.,/usr/include,, – John Jun 13 '16 at 14:05
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114539/discussion-between-john-and-sibicoder). – John Jun 13 '16 at 14:06
  • Include your home path in PATH variable in your .vimrc file and check. Like this : `:set path+=/home/John/src/**5`. **5 means 5 levels of subdirectiores. – SibiCoder Jun 13 '16 at 14:13
  • You could try to set `jedi.settings.auto_import_modules.append('bpy')`. `context` might not be completable, because it's too complicated for Jedi to resolve. The command above will just import bpy for all cases. – Dave Halter Jun 13 '16 at 17:09

3 Answers3

2

I just realized that there's not a lot of hope, because you're already talking to a compiled (C/C++) module.

If dir(bpy.context) (in a Python shell) doesn't give you the completions that you want, Jedi will also not be able to infer this information. If dir gives you something reasonable, just create an issue in the Jedi issue tracker. It would be a bug, IMO.

I'm planning a plugin system for Jedi, to make it possible to use Jedi with such use cases as well. But this will probably take two years.

Dave Halter
  • 15,556
  • 13
  • 76
  • 103
  • Nope. That did not give any useful output. I'll just wait the two years. Thanks. – John Jun 14 '16 at 10:02
  • 1
    Dave - I expect you will get more questions about blender auto-complete as this is coming up more often. See my answer to this as blender's bpy module is not a normal python module and would need extra setup outside of your project. – sambler Jun 14 '16 at 10:19
2

This often catches people out. Blender's bpy module is a compiled module created from source code within blender. The binary for the module is merged into blender's binary and is not made available outside of the python interpreter within blender.

It is possible to compile blender yourself and enable an option to build blender as a python module that you can import into any python interpreter, and will probably be the solution you are looking for.

In this answer you can also find some links to other answers that have tips for using eclipse and pycharm with blender that may be of some help.

Community
  • 1
  • 1
sambler
  • 6,917
  • 1
  • 16
  • 23
-1

Blender Python Text Editor, IDE there is this new tool Bacutor, has intellisense, syntax Highlight and more

http://bacutor.freeiz.com

Ali
  • 2,702
  • 3
  • 32
  • 54
  • try to highlight the keywords and be clear with the format it will help to reach out your answer for others – Agilanbu Dec 12 '18 at 07:36