$ 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从以下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与loader.py在同一目录中。它在我的dev box上工作,我做了一个svn导出到staging,上面发生了。有什么建议吗?
我能解决的唯一实质性区别就是这次我要用完virtualenv了。
编辑:我将命令行改为:
$ bin/python src/app/utils/loader.py utils.newTasks checkForStuff 并且模块被发现是正常的。但是我的下一个命令是调用其中一个模块函数checkForStuff
parser.add_argument('func',metavar='function', help="the target function name")
...
func_param = getattr(module,args.func)现在它找不到函数了?
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'如果我进入bin/python:
>>> import utils.newTasks as nt
>>> nt.checkForStuff
<function checkForStuff at 0x29b2f50>这太烦人了!
发布于 2012-11-23 08:28:39
bin/python不是登台机器上的Python二进制文件。检查是否像普通python一样将脚本目录插入到sys.path中。
https://stackoverflow.com/questions/13521647
复制相似问题