I have compiled Blender 2.79b as a Python3 module on Ubuntu 16.04 LTS. I install an addon using bpy.ops.wm.addon_install()
, enable it using bpy.ops.wm.addon_enable(module='packageName)
and save the user preferences using bpy.ops.wm.save_userpref()
. However, after I open Python3 again and do import bpy I cannot see the addon API's being added to the bpy module. If I run the same exact "addon installation" script when using Blender with the GUI everything works fine, but not when I have compiled Blender as a Python module. So I wonder, does anyone know whether I'm doing something wrong and how I can fix this?
In case you're wondering, I am trying to install Armory addon and below is the script I used to do the installation:
installArmory.sh
wget -O armsdk.zip https://www.dropbox.com/s/a17prr2hzsjkfog/armsdk.zip?dl=1
python3 installArmory.py
installArmory.py
import bpy, os, zipfile
with zipfile.ZipFile("armsdk.zip","r") as zip_ref:
zip_ref.extractall(os.getcwd() + '/')
# Install the addon
bpy.ops.wm.addon_install(filepath=os.getcwd() + '/armsdk/armory/blender/addon/armory.py')
bpy.ops.wm.addon_enable(module='armory')
# Set the SDK path
user_prefs = bpy.context.user_preferences
addon_prefs = user_prefs.addons['armory'].preferences
addon_prefs.sdk_path = os.getcwd() + '/armsdk'
bpy.ops.wm.save_userpref()
user_prefs.addons
before and after callingbpy.ops.wm.read_homefile()
. That would mean opening a blend after read_homefile or enable addons each time you start python and import bpy. $\endgroup$