Error "No such file or directory" when running Django ./manage.py

12,203

Solution 1

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.

Solution 2

The #! hash-bang line doesn't point to your virtualenv python; replace the first line with:

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

Solution 3

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).

Solution 4

In my case, I was erroneously changing the sys.path in my manage.py.

Solution 5

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.

Share:
12,203
msampaio
Author by

msampaio

Music Teacher

Updated on June 26, 2022

Comments

  • msampaio
    msampaio almost 2 years

    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]?