0
$\begingroup$

I want to know how I can import a .py file from the blender directory without having to write the whole path?

Currently this is what I'm doing:

import sys
sys.path.insert(0, r"C:\Users\userA\Downloads\blender-2.78-windows64\2.78\scripts\addons\io_anim_bvh")
import import_bvh
$\endgroup$

1 Answer 1

2
$\begingroup$

The addons path(s) is already known to blender, hence you can import from any addon within a scripts/addons folder, without the need to alter sys.path.

from io_anim_bvh import import_bvh, export_bvh 
from space_view3d_copy_attributes import rotcopy

whether the addon you are importing from is registered or not.

There is also the scripts/modules folder. Packages located there can be imported directly (akin to site-packages)

import osmium as o #  pyosmium 
$\endgroup$
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .