Django的manage.py问题
为什么我必须运行python manage.py somecommand
而其他人只需运行manage.py somecommand
?我使用的是 OSX 10.6。这是因为有一种预设方法可以使 .py
文件自动作为 Python 脚本运行,而我以某种方式禁用了该功能,还是您明确启用了该功能?
Why is it that I have to run python manage.py somecommand
and others simply run manage.py somecommand
? I'm on OSX 10.6. Is this because there is a pre-set way to enable .py
files to automatically run as Python scripts, and I've somehow disabled the functionality, or is that something that you explicitly enable?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您使用的是最新版本的 Django,则默认情况下,manage.py 文件应该是一个“可执行”文件。
请注意,您不能只在终端中输入
manage.py somecommand
,因为 manage.py 不在 PATH 上,您必须在它之前输入 ./ 才能从当前目录运行它,即 <代码>./manage.py somecommand。如果这不起作用,请确保 manage.py 文件具有:
#!/usr/bin/env python
作为它的第一行。并确保它是可执行的:
chmod +x manage.py
If you are using a recent version of Django, the manage.py file should be an "executable" file by default.
Please note, you cannot just type
manage.py somecommand
into the terminal as manage.py is not on the PATH, you will have to type ./ before it to run it from the current directory, i.e../manage.py somecommand
.If that does not work please be sure that the manage.py file has:
#!/usr/bin/env python
as its first line. And make sure it is executable:
chmod +x manage.py
您应该查看两件事:
首先,manage.py 脚本是否设置为可执行?如果没有,请尝试
其次,manage.py 是否有有效的 hashbang 行?如果没有,您可以尝试添加一个指向您系统的正确 python 解释器。
There are two things you should look at:
First, is the manage.py script set to be executable? If not, try
Secondly, does manage.py have a valid hashbang line? If not, you could try adding one that points to the correct python interpreter for your system.
在 Mac 上,manage.py 命令必须是可执行的,才能在没有 python 命令的情况下运行它。您可以通过以下方式执行此操作:
如果您与 manage.py 位于同一目录中,则要运行它,请键入:
否则您要指定路径:
On the mac the manage.py command has to be executable to just run it without the python command. You can do this with:
If you are in the same directory as manage.py, to run it you type:
Otherwise you want to specify the path: