3
$\begingroup$

How to get the value of this variable ?

enter image description here

$\endgroup$
1
5
$\begingroup$

An add-on is just a regular python module so there are multiple ways to get the actual path.

You can use addon_utils, a module for addon management that comes with blender to filter the add-on and get the path:

import addon_utils
for mod in addon_utils.modules():
    print(mod.bl_info.get("name"))
    print(mod.__file__)

Or you can iterate through all enabled addons and use sys.modules dict:

import bpy
import sys

context = bpy.context

for mod_name in context.preferences.addons.keys():
    mod = sys.modules[mod_name]
    print(mod.__file__)

Related: How can I get a list of the installed addons using the API?

$\endgroup$
1
  • $\begingroup$ Do you happen to know how to get the path to the adonns, knowing only the N-panel ? !image $\endgroup$
    – jora
    Mar 16 at 23:46
1
$\begingroup$

Blender addon utils module can fetch the path of any given addon name if installed.

#iterate through all the addon name installed
#if The Addon Name exists then: 
#.__file__ will give away the file path where it is installed
#We are printing the file path in console
#If the given name does not exist it will pass

import bpy
import addon_utils

for mod in addon_utils.modules():
    if mod.bl_info['name'] == "The Addon Name":
        filepath = mod.__file__
        print (filepath)
    else:
        pass
$\endgroup$
1
  • $\begingroup$ Hi, thanks for the post. This site is not a regular forum, answers should be substantial and thoroughly explain the solution and required workflow. One liners and code without context rarely make for a good answer. If you can edit your post and provide some more details about the procedure and why it works feel free to restore it, otherwise it may be deleted or converted into a comment. See How do I write a good answer? $\endgroup$ Nov 10 at 21:52

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.