yade-users team mailing list archive
-
yade-users team
-
Mailing list archive
-
Message #12234
Re: [Question #286282]: Load python module from within YADE
Question #286282 on Yade changed:
https://answers.launchpad.net/yade/+question/286282
Status: Open => Answered
Jan Stránský proposed the following answer:
Hello,
importing in Yade is the same as importing to normal Python [1,2]
"ImportError: No module named anyModule".
it means, that Python could not find the file anyModule.py. See [2] for
some details. You have several options:
1) The easiest way, have anyModule.py in the same directory as your main
script (bouncingSphereForum.py)
If you have the module in another place (to be used by more scripts for
instance), it is convenient to place it to some "standard" place (e.g.
myModules directory in your home directory), than you have 2 other options
2) using sys.path
#######
import sys
sys.path.append("/home/myname/path/of/the/directory/where/anyModule/is/saved")
import anyModule
#######
3) using PYTHONPATH, see [2].
cheers
Jan
[1] https://docs.python.org/2.7/tutorial/modules.html
[2] https://docs.python.org/2.7/tutorial/modules.html#the-module-search-path
--
You received this question notification because your team yade-users is
an answer contact for Yade.