Django manage.py question
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 automa开发者_如何学编程tically run as Python scripts, and I've somehow disabled the functionality, or is that something that you explicitly enable?
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
There are two things you should look at:
First, is the manage.py script set to be executable? If not, try
chmod u+x manage.py
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.
On the mac the manage.py command has to be executable to just run it without the python command. You can do this with:
chmod 755 manage.py
If you are in the same directory as manage.py, to run it you type:
./manage.py somecommand
Otherwise you want to specify the path:
/path/to/my/project/manage.py somecommand
精彩评论