Hi I’m trying to use multiple python files in my Blender3D script. (eg. MyScript.py and MyModule.py). MyScript.py looks like:
import bpy
import math
from add_utils import AddObjectHelper, add_object_data
import mathutils
# this line doesn't work
import MyModule
#### REGISTER ####
def register():
pass
def unregister():
print("Finished")
if __name__ == '__main__':
register()
Running the script within Blender3D, I get the error:
"ImportError: No module named MyModule"
I have setup Blender3D’s “script” folder to point at the folder containing my script and MyModule.py.
Thanks for any help.
J
Something has to add the proper path to the
sys.pathvariable. I don’t know it for Blender specifically, but in general, you could add it as follows:The one to use depends on the conditions you are running under: if your script is in some (for Blender) dedicated scripts folder, you could use the first one. If you run it from (for example) a
Program Filesfolder, use the absolute path.