I'm typing django-admin.py startproject project in my vscode terminal on windows, but when I do it just flashes a screen then closes and the project isn't created. It asked me what to open with and I chose python, but the command doesn't do anything. I'm not getting errors either
I was using django-admin.py instead of django-admin, problem is solved
Also you can create django app by typing folliwing command in terminal
python manage.py startapp HelloWorld
Note- It requires already created project.
whenever i give
django-admin.py startproject
i get a notepad of django-admin. So that means i type in my website inside that ?
i have executed the django-admin.py and django-admin.pyc in cmd also. Still it shows. What should I do ?
You have - for some reason - created a virtual environment inside the actual Python source directory on Windows.
There is nothing wrong with this, except you may face issues when you uninstall or upgrade Python.
To fix your immediate problem, you need to follow these steps:
Close all command prompt windows.
Open a new command prompt.
Type the following and hit ENTER which will activate your virtual environment:
C:\Python27\Scripts\pymote_ven\Scripts\activate.bat
Now, type the following to start your project:
python django-admin.py startproject nameofyourproject
You should also read the documentation because you have confused the directories that are involved.
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)
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.
In the past I have had a similar issue on windows. I found that using django-admin as listed below worked.
django-admin.py startproject myproject
I found that it was easy to copy the file django-admin.py into the folder that I wanted the stuff in. Navigate to the file in the command line and then run.
'python django-admin.py startproject myProject'
I have just started using python3.4 and I found everything (packages like pip and django) in c:\pythonpath\scirpts dir. Added that into system path and everything works good. e.g. django-admin startproject mysite
Am new to django and i have been trying to set up a project with no success. When i type
django-admin.py startproject mysite i get this.
C:\Users\WASSWA SAM\Documents\django\djcode>django-admin.py startproject mysite
Usage: django-admin.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=all output
etc....
I have added it to my path like so
C:\Python26\Lib\site-packages\django\bin
And when i import django from interactive mode it works perfectly. What could be the problem. I am using Windows 7 and django 1.3.1. I installed it using setup.py.
I had the same problem; I found a working solution at https://groups.google.com/forum/#!msg/django-users/b76qSG3mV6g/jP1o0ny3i2kJ:
python C:\Python27\Scripts\django-admin.py startproject mysite
This is an error with Python's installation on Windows. If you have the regkey entry
HKEY_CLASSES_ROOT\py_auto_file\shell\command\open\
change the value from
"C:\Python27\python.exe" "%1"
to
"C:\Python27\python.exe" "%1" %*
(Or your equivalent installation location)
This ensures that command-line arguments are passed onto python, rather than explicitly ignored. This is fixed in the latest install of Python 2.7. %* is argv[]. "%1" is the script's absolute path.
I had the same problem and could not solve it for hours. Create a new project from Pycharm or any other program you are using, install Django and then instead of running
django-admin.py startproject *project_name* .
run
django-admin startproject *project_name* .
Ommiting .py extension worked for me and everything is running as expected now.
I don't think you need to have django\bin in the path.
I think what you need to add to your PATH though is C:\Python26\scripts and then you should be able to run the startproject script.
In my case, I use eclipse and you can start an eclipse project from within the eclipse environment using PyDev.
Go up to File > New > Other > (within the PyDev Folder) > PyDev Django Project. In the wizard it will allow you to setup most of the commonly used features of Django.
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?
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>
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.
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.
For me worked without .py extension, since there was .exe by that name in my windows:
C:\Python27\Scripts\django-admin startproject HelloWorld
Try for this commond:
django-admin startproject mysite
instead of django-admin.py startproject mysite.
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.
Go on to c:/python**/Scripts/ you must find django-admin.py there that fixes your problem use the absolute path.
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
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.