django runscript 找不到脚本“myscriptnamehere.py”的(有效)模块

jay*_*ehm 2 python django python-2.7

Python 版本:Ubuntu 14.04 上的 2.7.6。
运行脚本 --version 1.10.4

我的脚本以前工作过。我不确定它们何时停止,但现在没有脚本会使用命令python manage.py runscript myscriptname.py 运行。我已经剥离了一个测试脚本来打印一行,没有导入,它仍然出错。
示例脚本:

def run(*args):
    print "hello"
Run Code Online (Sandbox Code Playgroud)

我一直收到错误“找不到脚本'myscripthere.py'的(有效)模块”。当我使用 -v2 选项时,我可以看到它检查所有各种应用程序和目录,然后它失败了。

如果我插入一行我知道应该抛出错误的行,它会抛出该行的错误。IE:

def run(*args):
    this line is garbage and will thrown an error
    print "hello"
Run Code Online (Sandbox Code Playgroud)

Ala*_*air 5

.py指定要运行的脚本时不应包括在内。将您的命令更改为:

python manage.py runscript myscriptname
Run Code Online (Sandbox Code Playgroud)