I have a problem in setting up django.
My situation: I have Anaconda Python 2.7 in my Windows 8 computer. On the Anaconda command prompt window, I type: pip install django
. This is successful.
Then I create a folder named "newproject". On the command prompt I went to the folder "newproject". Then django-admin.py startproject newproject
. This is successful.
Then I run python manage.py runserver
. It tells me
"...can't open file 'manage.py': [Errno 2] No such file or directory"
I checked out udemy django installation guide and other guides on the net. I have even set up a virtual environment. But the main problem is always: can't open file 'manage.py'
You're not in the proper directory...In the case you described, you should have:
mkdir newproject
(not sure why you're doing this...but we'll continue with it)cd newproject
django-admin.py startproject newproject
cd newproject
← A key missing part from what you did. You need to change into the directory where manage.py resides. Verify it by usingls
at the command prompt after switching into the directory.python manage.py runserver
Use ls
often, if you need, to double check where you are in the directory tree.
For me it was because the manage.py didn't get created and the problem was that:
In windows instead of typing "django-admin.py" just type "django-admin" and it will create the manage.py file
The reason of this problem is because you're in the first project directory "parent directory", and you have to go to your project "newproject" that has the manage.py file.
The way to this is simple:
cd "name of your project", E.g. cd newproject
python manage.py runserver
you need to change your directory to the directory of the project.
- open your environment by typing
activate environment_name
- change the directory to the folder in which you want to create the
project by
cd Folder_Name
- then create your project by
django-admin startproject Project_Name
- then change the directory to your project folder
- if you also want to create an app then type
python manage.py startapp App_name
- to confirm if it works type
python manage.py runserver
, then you should get a link in the terminal. copy and paste that link in the browser and you should see a successful page.
You are not in the correct directory. You need to do cd newproject and the execute your runserver command.
That can happen because manage.py doesn't have permissions. Check the existence of manage.py throughout newproject, If exist you can fix it with:
$cd newproject
$chmod +x manage.py
Finally, try to execute python manage.py runserver
I was having the same problem, when Windows 10 changed credentials, Docker lost the access to drives. The fix for this issue, I reset the credentials in docker-desktop > shared Drives > reset credentials at bottom.
can't open file 'manage.py': [Errno 2] No such file or directory"
here is the solution
step 1: command -> django-admin startproject project_name
step 2: command -> cd project_name
step 3: command -> python manage.py startapp app_name
try it may fix your problem
You need to include a .
after you create the project.
Eg: django-admin.py startproject newproject .
This will allow you to run python manage.py runserver
from where you are.
来源:https://stackoverflow.com/questions/36131744/cannot-open-manage-py-after-installing-django