Lynob
Lynob

Reputation: 5327

can't create django project using Windows command prompt

if i run

django-admin.py startproject mysite

django-admin.py (which is located in C:\python27\scripts/django-admin.py) will open in a file editor (now it opens in python ide, but in the past i had pype so it would open in pype) so the file opens:

#!C:\Python27\python.exe
from django.core import management

if __name__ == "__main__":
    management.execute_from_command_line()

i see no output in the command prompt at all, so lets say i typed

C:\abc:>django-admin.py startproject mysite

when I hit enter i see C:\abc>

and the project will not be created using the command prompt

this issue is not new for me, i'm creating my python projects using pydev, i would love to fix this issue with the command prompt though :)

@slugonamission

when I run

pyhon django-admin.py startproject mysite

the output of the command prompt is

python: can't open 'django-admin.py' file : [Errno 2] No such file or directory 

Upvotes: 11

Views: 12389

Answers (6)

GEEX programmer
GEEX programmer

Reputation: 51

This often happens in Windows.

  1. Open cmd at any location you want.
  2. enter django-admin startproject ProjectName (don't add the .py extension to the admin)
  3. Your project folder with all necessary files will be created there.

This is because the .exe file is supplied inside the directory.

Upvotes: 5

manali
manali

Reputation: 1

Using the Bitnami Django Stack

> cd C:\Users\user_user_name\Bitnami Django Stack projects
C:\Users\user_user_name\Bitnami Django Stack projects>
> python C:\Bitnami\djangostack-1.8.17-0\apps\django\Django-1.8.17-py2.7.egg\EGG-INFO\scripts\django-admin.py --version
> python C:\Bitnami\djangostack-1.8.17-0\apps\django\Django-1.8.17-py2.7.egg\EGG-INFO\scripts\django-admin.py startproject projectname

That works for me.

Upvotes: -2

Jarrod
Jarrod

Reputation: 1705

For anyone else who has this issue:

Try taking out the '.py'

django-admin startproject helloworld

Upvotes: 3

TheDataGuy
TheDataGuy

Reputation: 381

I'm using python 2.7 , django 1.7 in windows7.

WAY-1:

1) Go to C:\Python27\Scripts (or your installation directory)

2) open cmd and enter python django-admin-script.py startproject ProjectName

3)Your project folder with all necessary files ll be created there.

The problem is in windows, django-admin.py is supplied as django-admin-script.py

WAY2:

1)Open cmd at any location you want.

2)enter django-admin startproject ProjectName

3)Your project folder with all necessary files ll be created there.

Its because the .exe file is supplied.

Upvotes: 6

SuhasKhulpe
SuhasKhulpe

Reputation: 56

firstly find out where the django-admin.py is located then go to that path and then run the command django-admin.py startproject projectName i hope it will help you......best luck

Upvotes: 2

slugonamission
slugonamission

Reputation: 9632

I don't think Windows supports the shebang line. Try invoking it with python django-admin.py ...

Upvotes: 13

Related Questions