Reputation: 3433
In my django
project, the command ./manage.py [command]
results in this error message:
: No such file or directory
The command python manage.py [command]
works well. I tried with syncdb
and runserver
.
I tried chmod a+x manage.py
, but the problem persists.
My manage.py:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
I use django 1.4.1 in a virtualenv
.
How can I fix this to use manage.py [command]
?
Upvotes: 7
Views: 13039
Reputation: 468
In my case on Windows 7, every else it seems to be, but I've accidentally added an import in a views.py file:
from Scripts.pilprint import description
My software doesn't need this import, maybe with some wrong short-kut, my Eclipse wrote it for me, but removed this line, the problem disappear.
I suppose that description contain some painful character or have a wrong encoding for Windows.
Upvotes: 1
Reputation: 8325
Likely, the reason is because your line endings in the manage.py file are \n instead of \r\n. As a result the #! hash-bang is misinterpreted.
This happens to me when I use a Windows based text-editor for my linux connection.
Upvotes: 10
Reputation: 701
In my case, I was erroneously changing the sys.path
in my manage.py
.
Upvotes: 1
Reputation: 57418
In my django project, the command ./manage.py [command] results in this error message:
: No such file or directory
The command python manage.py [command] works well
If specifying the interpreter makes it work, then it is the first line that must be wrong:
#!/usr/bin/env python
Try:
#!/usr/bin/python
(or wherever the interpreter is. Find it with: which python
).
Upvotes: 3
Reputation: 1122572
The #!
hash-bang line doesn't point to your virtualenv python; replace the first line with:
#!/path/to/virtualenv/bin/python
Upvotes: 6