4
$\begingroup$

I'm trying to develop some blender plugins in VSCode. I'm familiar with writing python in VSCode, and thought that I could install bpy like any other python module so I could have intellisense features (i.e, Jump to definition, autocomplete) for bpy like I would any other python module installed in my virtual environment.

But from `pip install bpy` Not Working (LookupError: unknown encoding: future_fstrings) I gather that there is no "official" bpy module to install.

What options does this leave me if I would still like intellisense features for bpy while writing my plugin?

import bpy #can't install bpy and get intellisense
import geomdl #can install other python modules and get intellisense

from bpy.types import Panel

class SF_PT_PANEL(Panel):
   #my plugin panel script...

$\endgroup$
1

2 Answers 2

1
$\begingroup$

After trying to get blenderpy working, I kept running into install issues. Doesn't look like the project recieves much active support.

After more research I found fake-bpy-module, which got intellisense working.

$\endgroup$
1
$\begingroup$

Just to unpack @ANimator120's answer and the fake-bpy gitpage itself:

To get the fake-bpy-module working on VScode in Windows:

  • Install the package: from VS code terminal: py -m pip install fake-bpy-module-latest
  • go to file->preferences->settings
  • search for autocomplete python
  • open settings.json it aill add the extra paths section at the bottom.
  • you need to add the path to the site packages of your python dir (not the bpy folder like they say in the instructions) py -m site will help you here.

      "python.analysis.extraPaths": [
        "C:\\Users\\YourUserNameHere\\AppData\\Local\\Programs\\Python\\Python310\\Lib\\site-packages",       
      ],
  • Finally, I had to throw down a # pylint: disable=fixme, import-error before the import bpy to make the linter stop complaining that it still cant actually import this.

  • You should now have autocomplete

enter image description here

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .