21👍
You’re confusing two ways of referring to an executable file.
/usr/local/bin
is in your path, and django-admin.py
is marked as executable, so you can refer to it without the initial python
:
django-admin.py startproject myproject
When you start with python
, that is saying “start Python with the script at this path”. So, you need to pass the full path, if the script you’re trying to start isn’t in your current directory.
4👍
python django-admin.py
– Python execute file django-admin.py
in the current working directory.
If you add /usr/local/bin
into the PATH
environment variable, you can just issue django-admin.py
instead of python /usr/local/bin/django-admin.py
.
-
Check whether PATH contains
/usr/local/bin
echo $PATH
-
If there’s no
/usr/local/bin
in the variable, add that:export PATH=$PATH:/usr/local/bin # sh, ksh, bash, .. set path = ($path /usr/local/bin) # csh
- How does one use a custom widget with a generic UpdateView without having to redefine the entire form?
- Cannot import name HttpResponse
- How do you convert a Word Document into very simple html in Python?
- Django: generate download link
4👍
Use django-admin.py startproject
without the python.
You don’t need to use python with the django-admin.py startproject
, it should work from any directory. Only on windows you need to specify the full path.
django
runs the admin
script from the python interpreter
in your path
.
2👍
For windows users, just do django-admin startproject myproject
to use the django-admin.exe tool.
1👍
I had a similar issue with a different python script. Adding the shebang
#!/usr/bin/env python
to the top of the script and having it my path did the trick and allowed me to call it directly as in script.py
rather than python full/path/2script/script.py
0👍
Go to /usr/local/bin and change the permission of ‘django-admin.py’ as non executable then everything should work fine.
- Django ORM SELECT with join
- Django custom for complex Func (sql function)
- What's the difference between python objects and json objects?
- Display foreign key columns as link to detail object in Django admin
0👍
I had the same issue, I did check my /usr/local/bin but django-admin was missing instead it was in /usr/bin.
Later I tried below commands by executing the command in the workspace directory and it created projected for me.
python /usr/bin/django-admin startproject projectname
/usr/bin/django-admin startproject projectname
- Django – inline – Search for existing record instead of adding a new one
- Raise ValidationError from pre_save receiver function?
- Django datetime field – convert to timezone in view
- Django + Emacs (as TextMate replacement)
0👍
Problem:
python: can’t open file ‘django-admin.py’: [Errno 2] No such file or directory
Cause: We get this error when we write python code in notepad & saving it as .py extension. But command line will treats it as .py.txt
Solution: Just type python and drag the above file into the cmd prompt & then press enter.
Then sure u get it.
0👍
Try this django-admin.py startproject youproname
i also got the same problem when i installed django in my ubuntu just use the above one it will definately work
- Django template and dictionary of lists
- Id is not present in validate() and ListSerializer's update() Django Rest Framework