I have been trying to enable Blender addons from Python. I used the following code to implement it:
def enable_addon(addon_module_name):
loaded_defaults, loaded_state = addon_utils.check(addon_module_name)
if not loaded_state:
addon_utils.enable(addon_module_name)
enable_addon('object_print3d_utils')
enable_addon('object_boolean_tools')
It works for object_print3d_utils, but not for object_boolean_tools, and I'm not sure what could be reason. I get the following error:
RuntimeError: Error: Python: Traceback (most recent call last): File "/Applications/blender.app/Contents/Resources/3.2/scripts/addons/object_boolean_tools.py", line 468, in execute Operation(context, self.mode) File "/Applications/blender.app/Contents/Resources/3.2/scripts/addons/object_boolean_tools.py", line 111, in Operation prefs = context.preferences.addons[name].preferences KeyError: 'bpy_prop_collection[key]: key "object_boolean_tools" not found'
Thank you for any help in advanced!
default_set=True, see https://blender.stackexchange.com/q/242762/88681. – scurest Jul 21 '22 at 22:57default_set=Trueargument, as @scurest said,addon_utilstreats disabled addons as if they don't exist. This is why you get the key error. I don't know if it is a bug or a feature but it is annoying. – Marty Fouts Jul 21 '22 at 23:50