Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django--django-admin.py on windows does not work

Tags:

python

django

I am just starting Django these days but I cannot run this command

    django-admin.py startproject myproject

Well, CMD does not prompt to say that this command is not recognized. Instead, it just open up my Sublime with the file django-admin.py open. and of course no folder named myproject is created inside the current folder.

I managed to start a Django project by typing commands like

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

But when I omit the part about the absolute path information of django-admin.py, then the command does not work, saying python cannot find such a file inside the current directory.

is there any way I should try to use shorter commands? (PS: I do have C:\Python27\ and C:\Python27\Scripts\ in the PATH)

like image 436
Junchao Gu Avatar asked Oct 25 '13 15:10

Junchao Gu


1 Answers

The easiest way (recommended by the docs) is to just copy django-admin.py to your project's directory.

Technical details: There are workaround in setuptools to make entry points work correctly on Windows, by installing a .exe file that will run correctly even if Python is not set as the default handler for .py files, but Django is not using setuptools but distutils directly. I am not aware of any discussion about moving to setuptools.

Alternatively you can set python.exe as the default program to open .py files, instead of your text editor.

like image 103
remram Avatar answered Sep 19 '22 01:09

remram