R
rkmr.em
Hi
I have a function data['function'], that I need to import from a file
data['module'], in the directory data['cwd']
If I do this from python interactive shell (linux fedora core 8) from
dir /home/mark it works fine:
cwd = data['cwd']
os.chdir(cwd)
print os.getcwd()
module = __import__(data['module'])
function = getattr(module, data['function'])
But if I put this in a file /home/mark/work/common/funcq.py and run it
from /home/mark, it throws me error like this.. how to fix this? it
imports the module successfully, but it is not looking for subsequent
modules in the os.getcwd()..
/home/mark/work/proj1
Traceback (most recent call last):
File "/home/mark/work/common/funcq.py", line 60, in <module>
if __name__ == '__main__':do()
File "/home/mark/work/common/funcq.py", line 33, in do
module = __import__(data['module'])
File "/home/mark/app.py", line 5, in <module>
import abcde
ImportError: No module named abcde
I have a function data['function'], that I need to import from a file
data['module'], in the directory data['cwd']
If I do this from python interactive shell (linux fedora core 8) from
dir /home/mark it works fine:
cwd = data['cwd']
os.chdir(cwd)
print os.getcwd()
module = __import__(data['module'])
function = getattr(module, data['function'])
But if I put this in a file /home/mark/work/common/funcq.py and run it
from /home/mark, it throws me error like this.. how to fix this? it
imports the module successfully, but it is not looking for subsequent
modules in the os.getcwd()..
/home/mark/work/proj1
Traceback (most recent call last):
File "/home/mark/work/common/funcq.py", line 60, in <module>
if __name__ == '__main__':do()
File "/home/mark/work/common/funcq.py", line 33, in do
module = __import__(data['module'])
File "/home/mark/app.py", line 5, in <module>
import abcde
ImportError: No module named abcde