"No such file or directory" error when starting Django./manage.py

In my project, the djangocommand ./manage.py [command]raises this error message:

: No such file or directory

The team is python manage.py [command]working well. I tried with syncdband 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 am using django 1.4.1 in virtualenv. How can I fix this to use manage.py [command]?

+5
source share
4 answers
Probably the reason is that your lines end in the file manage.py \ n instead of \ r \ n. As a result, #! hash bang is misinterpreted.

This happens to me when I use a Windows-based text editor for my linux connection.

+9
source

hash-bang #! ; :

#!/path/to/virtualenv/bin/python
+2

In my project django team. /manage.py [command] produces this error message:

: no such file or directory

Python manage.py command [command] works well

If specifying the interpreter makes it work, then this is the first line, which should be incorrect:

#!/usr/bin/env python

Try:

#!/usr/bin/python

(or wherever the interpreter is. Find it with which python).

+2
source

In my case, I mistakenly changed sys.pathin my own manage.py.

0
source

All Articles