yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #03659
Re: import module
> I have a question on how to import a module into a python script to be
> run with Yade. I do all as it should be, but apparently if in the
> script I include the line import myNameModule, on the console it says
> that "module myNameModule not found". OTHT, if I do not include this
> line in the script, but say I run one step and then on the console I
> type import myNameModule, then it can find it. Do you have the same
> problem? Would you know why this could happen just to me, eventually?
> Should I perhaps include yade.wrapper into the py module as long as it
> is using Yade objects?
You should say from "yade import *" in your module (that gives you all
yade classes and so on available); the command line does that
automagically for you.
If your mopdule cannot be found by the import statement, it means it is
not in the module search path (which does _not_ include the current
directory by default); you can fix that easily:
import sys
sys.path.append('.')
imporet myModuleName # ./myModuleName.py will be found then
see http://docs.python.org/library/sys.html#sys.path as well
Cheers, v.
References