Django-Admin. Py Startproject Is Not Working

after installing django I tried django-admin.py startproject mysite and that worked, then I got a simple site working and I wanted to start on something real, so I tried django-admin.py startproject newsite and nothing happened. Whenever I try the command nothing happens now.. any idea what is wrong?

14 Answers

For anyone stumbling across this now, this problem is a result of Windows not obeying the #!C:\Path\To\Virtualenv\Scripts\Python.exe hashbang at the top of django-admin.py, and therefore running it with the wrong python.exe (evidently a virtualenv bug).

However, with virtualenv active, you can use the following command, which will result in the correct python being used, and everything being ok:

python C:\Path\To\Virtualenv\Scripts\django-admin.py startproject <project_name>
3

If you are running Windows for a quick fix you can create a batch file with the following values:

@echo off
@echo "Enter Proyect name"
set /p proj_name=
set building="Building django project %proj_name%"
@echo %building%
python c:/Python27/Scripts/django-admin.py startproject %proj_name%
pause

I named the file "django.bat" and to use it you can just simply add a copy in the directory you want to start the project, execute the file and it will ask you for a project name, provide one and then Voila!!

Hope this helps.

1

Do you have a DJANGO_SETTINGS_MODULE environment variable set (presumably from the mysite project)? If so, django thinks you're working on the old project and doesn't give you the startproject option. Try unsetting the environment variable and trying again.

7

For me worked without .py extension, since there was .exe by that name in my windows:

C:\Python27\Scripts\django-admin startproject HelloWorld
0

If everything is installed properly, when you open the command prompt, navigate to the desktop folder with

cd C:\Users\YOURNAME\Desktop

then type

django-admin startproject YOURPROJECTNAME

The project should appear on your desktop.

If you didn't navigate to your desktop folder and run the command there, your project could be placed in the windows\system32 folder on the C drive.

2

Try for this commond:

django-admin startproject mysite

instead of django-admin.py startproject mysite.

2

Go on to c:/python**/Scripts/ you must find django-admin.py there that fixes your problem use the absolute path.

1

Try this instead! It also works inside virtualenv

python "C:\Python27\Scripts\django-admin.py" startproject test2

I'm on a Mac and had a similar problem after installing with pip3. I reinstalled and it corrected the error. You can try going to the #django irc channel at irc.freenodes

Try out this way.

1> Look where your python is installed if cannot find it in C:/ Python().

$ python
Python 2.6.6 (r266:84297, Aug 24 2010, 18:13:38) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'c:\\Python26\\python.exe'
>>> sys.exec_prefix
'c:\\Python26'
>>>
>>> print '\n'.join(sys.path)

c:\Python26\lib\site-packages\setuptools-0.6c11-py2.6.egg
c:\Python26\lib\site-packages\nose-1.0.0-py2.6.egg
C:\Windows\system32\python26.zip
c:\Python26\DLLs
c:\Python26\lib
c:\Python26\lib\plat-win
c:\Python26\lib\lib-tk
c:\Python26
c:\Python26\lib\site-packages
c:\Python26\lib\site-packages\win32
c:\Python26\lib\site-packages\win32\lib
c:\Python26\lib\site-packages\Pythonwin
c:\Python26\lib\site-packages\wx-2.8-msw-unicode

2> After that move into Scripts folder. There you may find django-admin.py. Now copy full path of that file.

3>Now run this command

python path of the file startproject name of Project

eg. python C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts\django-admin.py startproject mysite

hope this will work.

after years I have to answer this question because the answer is changed for WINDOWS now

python C:\Path\To\Virtualenv\Scripts\django-admin.exe startproject <project_name>

you can use .exe for windows in Scripts folder

Even I faced the same problem. I even tried adding the directory to Environmental variables but it was not working, so I had to use python -m django for it, but it didn't satisfy me, so I did a tricky thing.

Instead of adding the directory to Environmental variables, I copied the installed package and pasted it to the first directory (default directory) in environmental variable and it started working.

Try this solution:

1) Select a .py file and right click and select Open with...
2) Here select Python Launcher for Windows

This solution is provided for Windows OS

I have a easy solution for this. normally download the django-admin file from the web the add it to the python\script folder then add the C:\python\script to the environment variable then try the command i.e django-admin startproject

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Elena Rostova

Elena Rostova

Lead Health, Wellness & Medical Journalist

Elena Rostova holds a Master's degree in Public Health Journalism. She covers groundbreaking medical research, holistic wellness trends, mental health awareness, and nutritional science.

Share this article
Twitter Facebook Pinterest