# Can an add-on be automatically installed and enabled?

I am developing a program that will include a custom importer and exporter for blender.

I would like the installer for my program to be able to automatically install and enable the import/export python scripts. Here are the steps I think I need to do:

1. Find the blender add-on directory. My program is windows-only, so I presume this will just be in %appdata%\Blender Foundation
2. Copy my add-on files to a subdirectory of the add-on directory
3. Enable the plugin in blender
4. Save the user preferences so that the plugin stays enabled after a restart.

I can work out 1, and 2 is easy, but I'm not sure that 3 and 4 are even possible without using the UI. Is it possible to do them programmatically, perhaps via a python script that I launch with blender?

Part 1. Your user script paths

>>> bpy.utils.script_path_user(
script_path_user()
returns the env var and falls back to home dir or None
>>> bpy.utils.script_path_user()
'/home/batfinger/.config/blender/2.76/scripts'


>>> bpy.utils.script_paths(subdir='addons')


Part 3.

from the console

>>> from addon_utils import enable
>>> enable(
enable(module_name, default_set=False, persistent=False, handle_error=None)
:arg module_name: The name of the addon and module.
:type module_name: string
:return: the loaded module or None on failure.
:rtype: module


To enable my sound drivers addon for instance

enable("sound_drivers")


Check out the source, there are other handy addon utils in there.

and for part 4, there's the operator to save user prefs.

 bpy.ops.wm.save_userpref()

• Thanks for the timely answer, it pretty much solved all my issues. I'd upvote it, but my reputation is apparently too low. – mushin Sep 29 '15 at 14:49
• @mushin That is ok, you will soon have enough rep. For now you did your part in accepting his answer. Welcome to BSE. – David Sep 29 '15 at 16:15