0
$\begingroup$

I compiled Blender as python module successfully in Windows Platform. I can now import bpy without problems from my script. Now I would like use an add-on from my script but I receive this error:

AttributeError: Calling operator "bpy.ops.importgis.georaster" error, could not be found.

Obviously, because I haven't compiled this add-on. How do I compile it?

I solved this by enabling addon: bpy.ops.wm.addon_enable(module="BlenderGIS-master")

$\endgroup$
  • $\begingroup$ How did you compile Blender's bpy in the first place? $\endgroup$ – Bert VdB Nov 29 '17 at 10:34
  • 1
    $\begingroup$ I compiled it with CMake in Windows 10 following this example: cobertos.com/… $\endgroup$ – Giuseppe Nov 29 '17 at 11:28
  • $\begingroup$ It's not that the addon isn't compiled, it isn't enabled. Can enable addon in script using from addon_utils import enable and enable("BlenderGIS") .. could be a bit dodgy with this addon by the looks. Also checkout the code, may find a direct method via reading code, and using from BlenderGIS import ... making it possible to bypass using operator altogether. (eg see if operator just sets parameters and calls a function, and use that funciton) $\endgroup$ – batFINGER Nov 29 '17 at 13:12
  • $\begingroup$ I solved this by enabling addon: bpy.ops.wm.addon_enable(module="BlenderGIS-master") $\endgroup$ – Giuseppe Nov 29 '17 at 13:50
  • $\begingroup$ Nice, wasn't sure if window manager ops would work for bpy as py module. $\endgroup$ – batFINGER Nov 29 '17 at 13:56
2
$\begingroup$

About the title of the question: you cannot compile add-ons because they are written in Python*.

Your script causes this error because it wasn't registered with Blender. Use the normal way (i.e. the regular Blender UI) to enable your add-on, and be sure to save your preferences so that it stays enabled. Once that's done it should simply work, also with Blender compiled as a module.

(*) Little footnote: Python is compiled into bytecode, but by the Python runtime itself, and doesn't require any action from the user contrary to "compiled languages" like Go or C.

$\endgroup$
  • $\begingroup$ I would avoid the normal blender installation, because I only need the module for my custom script. Anyway I will try as your suggestion and I will let you know. Thank you so much $\endgroup$ – Giuseppe Nov 29 '17 at 11:25
  • $\begingroup$ You don't need a normal Blender installation, you just need to have your addon activated. The easiest way to do that in general is with the regular Blender UI, but @batFINGER also described another approach. $\endgroup$ – dr. Sybren Nov 30 '17 at 12:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.