Reputation: 2747
$ bin/python src/app/utils/loader.py newTasks checkForStuff
Traceback (most recent call last):
File "bin/python", line 135, in <module>
execfile(__file__)
File "src/app/utils/loader.py", line 154, in <module>
module = __import__(args.module)
ImportError: No module named newTasks
from the following loader.py:
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Runs python')
parser.add_argument('module', metavar='module', help="the target module")
args = parser.parse_args()
module = __import__(args.module)
newTasks.py is in the same directory as loader.py. It works on my dev box, I did an svn export to staging and the above happened. Any pointers?
Only material difference I can work out is this time I'm running out of virtualenv.
EDIT: I changed the command line to:
$ bin/python src/app/utils/loader.py utils.newTasks checkForStuff
and the module was found ok. But my next command is to call one of the module functions checkForStuff
:
parser.add_argument('func',metavar='function', help="the target function name")
...
func_param = getattr(module,args.func)
and now it cannot find the function?
Traceback (most recent call last):
File "bin/python", line 135, in <module>
execfile(__file__)
File "src/app/utils/loader.py", line 156, in <module>
func_param = getattr(module,args.func)
AttributeError: 'module' object has no attribute 'checkForStuff'
If I go into bin/python:
>>> import utils.newTasks as nt
>>> nt.checkForStuff
<function checkForStuff at 0x29b2f50>
This is annoying!
Upvotes: 2
Views: 399
Reputation: 414215
bin/python
is not the python binary on your staging machine. Check whether it inserts the scripts directory into sys.path as ordinary python does.
Upvotes: 1