3
$\begingroup$

Is there a clean way to get the absolute path to the scripts folder for the currently running version of Blender?

The following code works (on Windows) but it feels a bit hackish.

from os.path import dirname, join, normpath
from bpy.app import binary_path_python
normpath(join(dirname(binary_path_python), '..', '..', 'scripts'))

Results in C:\\Program Files\\Blender Foundation\\Blender\\2.77\\python\\scripts.

$\endgroup$
4
$\begingroup$

There is a few nice helper methods hidden in the bpy.utils module space. For instance, calling

bpy.utils.script_paths()

will return all current Blender paths where Python modules can be put. Even if you (like I do on my system) redirect the Scripts Folder to a custom location, so they stay around when updating Blender, using this method you'll get a valid pointer. See this output here:

scripts path

But you could also use

x = bpy.utils.script_path_user()

to retrieve the current location of your user scripts. This will return a string, and as a fallback your scripts home directory if no custom path was set.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Works perfectly. This let me find the bpy.utils API docs. Thanks! $\endgroup$ – MattMS Oct 2 '16 at 2:35

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.