Python: Can't Open File 'django-admin.py': [errno 2] No Such File Or Directory
Solution 1:
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.
Solution 2:
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
Solution 3:
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
.
Solution 4:
For windows users, just do django-admin startproject myproject
to use the django-admin.exe tool.
Solution 5:
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
Post a Comment for "Python: Can't Open File 'django-admin.py': [errno 2] No Such File Or Directory"