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
I don't think Windows supports the shebang line. Try invoking it with python django-admin.py ...
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.
This often happens in Windows.
Open cmd at any location you want.
enter django-admin startproject ProjectName (don't add the .py extension to the admin)
Your project folder with all necessary files will be created there.
This is because the .exe file is supplied inside the directory.
For anyone else who has this issue:
Try taking out the '.py'
django-admin startproject helloworld
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
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.
Related
When I am using django-admin startproject api then it is opening file name django-admin.py and the code looks like this :
#!C:\Users\Administrator\Desktop\api\venv\Scripts\python.exe
## When the django-admin.py deprecation ends, remove this script.
import warnings
from django.core import management
try:
from django.utils.deprecation import RemovedInDjango40Warning
except ImportError:
raise ImportError(
'django-admin.py was deprecated in Django 3.1 and removed in Django '
'4.0. Please manually remove this script from your virtual environment '
'and use django-admin instead.'
)
if __name__ == "__main__":
warnings.warn(
'django-admin.py is deprecated in favor of django-admin.',
RemovedInDjango40Warning,
)
management.execute_from_command_line()
I am using virtual environment. I am not getting how to get rid of it.
Short answer:
Use django-admin.exe instead of django-admin because django-admin.py is deprecated.
Example:
django-admin.exe startproject NEW_PROJECT_NAME
django-admin.exe startapp NEW_APP_NAME
Long answer:
If you use the command "where django-admin" (Windows) / "whereis django-admin" (Linux), you will see that there are probably two shortcuts.
In my case:
C:\Program Files\Python39\Scripts\django-admin.exe
C:\Program Files\Python39\Scripts\django-admin.py
I suppose that using an .exe extension file is faster than using the .py python extension file.
There may be another solution, I haven't tried to delete the file with "py" extension (django-admin.py), I just found that the fastest solution was to use "django-admin.exe startproject PROJECT_NAME", and so on.
The most straightforward way is probably to uninstall and reinstall Django in your virtual environment, if you're okay using the latest version of 3.2:
pip uninstall Django
pip install 'Django<4'
I've been trying to execute django-admin from within a LiClipse project using:
projectName = "someProject"
command = 'django-admin startproject ' + projectName
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE)
and also
subprocess.check_call(shlex.split(command))
But each time I get the error:
FileNotFoundError: [Errno 2] No such file or directory: 'django-admin'
However, when I run the same program from the Linux terminal using python3 main.py, it works fine.
So I figured it might be because django-admin's path isn't added to PYTHONPATH. I did a locate "django-admin" to find these paths:
/home/nav/.pyenv/shims/django-admin
/home/nav/.pyenv/shims/django-admin.py
/home/nav/.pyenv/versions/3.8.7/bin/django-admin
/home/nav/.pyenv/versions/3.8.7/bin/django-admin.py
/home/nav/.pyenv/versions/3.8.7/bin/__pycache__/django-admin.cpython-38.pyc
/home/nav/.pyenv/versions/3.8.7/lib/python3.8/site-packages/django/bin/django-admin.py
/home/nav/.pyenv/versions/3.8.7/lib/python3.8/site-packages/django/bin/__pycache__/django-admin.cpython-38.pyc
and added it to PYTHONPATH...
...but I get the same error when I run the program from within LiClipse.
Does anyone know why this problem is happening and how it can be fixed?
While creating a django project in windows using command prompt,I created a directory using mkdir djproject ->my directory name. Then when I tried creating a project using cd project -> my project name, I received the error message "the system cannot find the path specified".
(myproject) C:\Users\USER>django-admin --version
2.2.1
(myproject) C:\Users\USER>mkdir djproject
(myproject) C:\Users\USER>cd djproject1
The system cannot find the path specified.
(myproject) C:\Users\USER>django-admin --version
2.2.1
[1](myproject) C:\Users\USER>mkdir djproject <-- You created a directory named djproject
[2](myproject) C:\Users\USER>cd djproject1
The system cannot find the path specified. <-- This error is caused by [2],
because you're trying to cd into a directory that does not exist.
If you would type dir before the [2] command, you would see that the only folder is djproject. The correct syntax for creating a Django App is:
django startproject <your_app_name>
Im using python 3.5 and django 1.8.6 but whenever i call the django-admin startproject, it throws the syntax error, even when i call it in comand line. I dont know how to fix it. Please help me.
import django
>>> print (django.get_version())
1.8.6
>>> django-admin startproject mydite
SyntaxError: invalid syntax
>>>
You are supposed to run this from the command line, not from inside Python.
mkdir django_project
cd django_project
virtualenv env
source env/bin/activate
pip install django
#Then run
django-admin startproject mydite
If you have any questions go through
this link
I am a mac user and have never really used a pc from the command line.
How would I add django-admin.py to my path, so I can type in
> django-admin.py startproject newproject.
I suppoed I'd need to do the following:
1 - Find the python executable `django-admin.py`
2 - Add it to my system path
3 - > ln -s PATH/TO/django-admin.py <my system path>
I know this is a very newbie question, but I'm having trouble 'getting started' on a new windows system to create a new django project.
Just follow this tutorial. You need to add its full path to 'path' variable.
http://www.computerhope.com/issues/ch000549.htm