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]
?
How to Fix “python: can't open file 'manage.py': [Errno 2] No such file or directory” To fix the “python: can't open file” error, you need to go into the folder where manage.py is located. To do so, you need to type “cd mysite” at the terminal followed by “python manage.py runserver”.
The site could be temporarily unavailable or too busy. Try again in a few moments. If you are unable to load any pages, check your computer's network connection. If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
To run a task of the manage.py utilityOn the main menu, choose Tools | Run manage.py task, or press Ctrl+Alt+R . The manage.py utility starts in its own console. Type the name of the desired task.
The django-admin.py script should be on your system path if you installed Django via its setup.py utility. If it's not on your path, you can find it in site-packages/django/bin within your Python installation.
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.
The #!
hash-bang line doesn't point to your virtualenv python; replace the first line with:
#!/path/to/virtualenv/bin/python
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With