import module

hi, i’m try to import a module that i’ve made but blender keeps telling me it cant find it.

i’ve tryed the following


1) from . import startPanel
2) from startPanel import *
3)
if "bpy" in locals():
    import imp
    imp.reload(startPanel)
else:
    from . import startPanel

my file structure is the following: a main file and an startPanel file in the same folder.

if it is a folder in order for the above to work it should be a folder named startPanel and have inside a file named init.py which will contain all your code or import the module that contains your code. Or else it wont work. Read on python packages to understand why.

by the way you naming convention is not good, it better that the name of the folder to be start_panel and of course the same name should be used in your import commands and imp.reload

hi, i’ve read the doc and made the init file (left it empty) and wath i’m try to do is an Intra-package Reference. But blender wont find any file in my package.

this is my file struc now
/Documents/packageName/__init__py (this is empty)
/Documents/packageName/file1.py
/Documents/packageName/file2.py

i want to use func and classes from file1 in file2.
so in file2 i import file1 like this

import file1

and this does not work in blender when i run file2
it gives error NO module named file1

note the dir of blender is /Document/blender/…

thats wrong in many ways

first the modules should be in one blender path used for python modes

Dokuments ins not in that path unless you added it in the preferences

Second, you totally ignored my reply on how to use and call a package because if you did you will be importing like this

from packageName import file1

and I told you to read on python packages , or else you will be hitting your head against the wall. Coding is all about reading , and reading and reading and reading and if you made sure you have read all then read some more and then finally code. This is how we all learned, no way to go around it.