# Why the addon installation succeeds but the API is not accessible through the bpy module?

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() + '/')

# Set the SDK path
user_prefs = bpy.context.user_preferences

bpy.ops.wm.save_userpref()

• I don't believe loading the bpy module will read the startup file that has the enabled addons saved. Look at the length of user_prefs.addons before and after calling bpy.ops.wm.read_homefile(). That would mean opening a blend after read_homefile or enable addons each time you start python and import bpy. – sambler Sep 18 '18 at 5:09
• @sambler I think I found a [temporary] solution to this problem. See my answer – Amir Sep 18 '18 at 15:42

I think I could find a way around this but I don't think this will work for all addons that require restarting Blender, but it works for Armory.

Here are the steps:

# Install the addon
# Use the start() function of bpy.ops.arm_addon to enable it.

Now arm shows up in bpy.ops. I don't think all addons have a function like start() that Armory has.