75
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>
10
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.
- [Django]-Django Overriding Model Clean() vs Save()
- [Django]-Django: Detect database backend
- [Django]-Easily rename Django project
7
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.
- [Django]-Edit/show Primary Key in Django Admin
- [Django]-What's the differences between has_object_permission and has_permission?
- [Django]-Why doesn't memory get released to system after large queries (or series of queries) in django?
6
For me worked without .py
extension, since there was .exe
by that name in my windows:
C:\Python27\Scripts\django-admin startproject HelloWorld
- [Django]-Django, filter by specified month and year in date range
- [Django]-Getting 'str' object has no attribute 'get' in Django
- [Django]-Preventing django from appending "_id" to a foreign key field
5
Try for this commond:
django-admin startproject mysite
instead of django-admin.py startproject mysite.
- [Django]-What base_name parameter do I need in my route to make this Django API work?
- [Django]-Create celery tasks then run synchronously
- [Django]-Django FileField (or ImageField) open() method returns None for valid file?
3
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.
- [Django]-Django : Unable to import model from another App
- [Django]-Transaction managed block ended with pending COMMIT/ROLLBACK
- [Django]-How to create virtual env with python3
1
Go on to c:/python**/Scripts/ you must find django-admin.py
there that fixes your problem use the absolute path.
- [Django]-How can I trigger a 500 error in Django?
- [Django]-How to add clickable links to a field in Django admin?
- [Django]-Django unique_together with nullable ForeignKey
1
Try this instead! It also works inside virtualenv
python "C:\Python27\Scripts\django-admin.py" startproject test2
- [Django]-After adding django-debug to App, getting "'djdt' is not a registered namespace"
- [Django]-Convert an IP string to a number and vice versa
- [Django]-What is the correct way of returning an empty queryset in a Django View?
1
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
- [Django]-Pip install -r requirements.txt [Errno 2] No such file or directory: 'requirements.txt'
- [Django]-How to lookup django session for a particular user?
- [Django]-Django: change the value of a field for all objects in a queryset
0
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
- [Django]-How to add multiple arguments to my custom template filter in a django template?
- [Django]-Django 1.7 β App 'your_app_name' does not have migrations
- [Django]-Setting default value for Foreign Key attribute in Django
0
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
- [Django]-Customizing an Admin form in Django while also using autodiscover
- [Django]-How to serve django media files via nginx ?
- [Django]-What are the options for overriding Django's cascading delete behaviour?
0
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.
- [Django]-Django : DRF Token based Authentication VS JSON Web Token
- [Django]-Get path of virtual environment in pipenv
- [Django]-Django: get table name of a model in the model manager?
0
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.
- [Django]-Django REST Framework β pass extra parameter to actions
- [Django]-In Django 1.4, do Form.has_changed() and Form.changed_data, which are undocumented, work as expected?
- [Django]-Coercing to Unicode: need string or buffer, NoneType found when rendering in django admin
0
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
- [Django]-Django REST Framework: raise error when extra fields are present on POST
- [Django]-Any way to make {% extends 'β¦' %} conditional? β Django
- [Django]-Count frequency of values in pandas DataFrame column
0
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.
- [Django]-How can I apply a filter to a nested resource in Django REST framework?
- [Django]-Accessing the object in a django admin template
- [Django]-Create if doesn't exist
0
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.
- [Django]-Uwsgi installation error in windows 7
- [Django]-TemplateDoesNotExist β Django Error
- [Django]-Multiple authentication backends configured and therefore must provide the `backend` argument or set the `backend` attribute on the user