thank you all, this problem was solved
but I don't know What is the different between them
wrong script :
def func(module) :
cwd = os.getcwd()
os.chdir(module['path'])
tmp = __import__(module['name'])
os.chdir(cwd)
working well script :
def func(module) :
sys.path.append(module['path'])
tmp = __import__(module['name'])
...
happy new year :)
============================================================
Hello I need to import dynamically in python script
when I try __import__() outside of a function
ex)
__import__('myModule')
it does work, but when I try it within a function
ex )
def func() :
__import__('myModule')
func()
I get an ImportError: ImportError: No module named myModule
How can I use __import__() in function??
funcin a different module from the one where it worked?