Reputation: 16558
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?
Upvotes: 24
Views: 74105
Reputation: 324
Try for this command:
django-admin startproject mysite
instead of django-admin.py startproject mysite.
Upvotes: 7
Reputation: 1
I solved it by just closing and reopening VS code.
It seems it was a variable path issue. As always, VS code cannot read it unless it is closed and re-opened.
Hope it can help someone.
Upvotes: 0
Reputation: 1
the command "django startproject first" was not working for me so I used the command : python -m django startproject first this command worked for me on windows
Upvotes: -1
Reputation: 11
My project made the ".py" file into a ".exe" file. So instead of: "django-admin.py startproject"
I needed to do
> django-admin.exe startproject
It worked for me.
Upvotes: 0
Reputation: 1
If you have pip installed in that environment you can always download the Django in the virtual environment and use it to start your project like I did instead of downloading it from web or changing environment variables.
Upvotes: 0
Reputation: 13
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
Upvotes: 0
Reputation: 410
For me worked without .py
extension, since there was .exe
by that name in my windows:
C:\Python27\Scripts\django-admin startproject HelloWorld
Upvotes: 6
Reputation: 321
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
Upvotes: 0
Reputation: 1
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.
Upvotes: 0
Reputation:
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
Upvotes: 1
Reputation: 31
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.
Upvotes: 3
Reputation: 1
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.
Upvotes: 0
Reputation: 19206
Try this instead! It also works inside virtualenv
python "C:\Python27\Scripts\django-admin.py" startproject test2
Upvotes: 1
Reputation: 130
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
Upvotes: 0
Reputation: 11
Go on to c:/python**/Scripts/ you must find django-admin.py
there that fixes your problem use the absolute path.
Upvotes: 1
Reputation: 1463
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.
Upvotes: 10
Reputation: 766
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>
Upvotes: 75
Reputation: 123568
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.
Upvotes: 7