windows can't find django-admin.py

1,346 views
Skip to first unread message

tcp

unread,
Sep 19, 2008, 2:20:24 PM9/19/08
to Django users
Hi,

New to Python...getting started with Django.

I've just installed Django and and following some getting started
instructions.

I'm trying to run django-admin like this:

c:\myproject> python django-admin.py startproject iFriends

and I get this problem:

python: can't open file 'django-admin.py': [Errno 2] No such file or
directory

This shouldn't be surprising as django-admin.py is not in the current
working directory. The file is in C:\python\Django-1.0\django\bin.

I DO have C:\python\Django-1.0\django\bin on the PYTHONPATH. Here is
proof:

>>> import sys
>>> print sys.path
['', 'c:\\python\\Django-1.0\\django\\bin', 'C:\\Windows\\system32\
\python25.zip
', 'C:\\Python25\\DLLs', 'C:\\Python25\\lib', 'C:\\Python25\\lib\\plat-
win', 'C:
\\Python25\\lib\\lib-tk', 'C:\\Python25', 'C:\\Python25\\lib\\site-
packages']

So, why is python not finding the file that is on the PYTHONPATH. I
thought the PYTHONPATH was similar to a Java CLASSPATH? Do I
misunderstand?

Tom

Rodolfo

unread,
Sep 19, 2008, 2:32:45 PM9/19/08
to Django users
I guess for that to work you have to have it on Windows PATH env.
variable, and not PYTHONPATH.
That's cuz Windows can't find the file you're passing to python.

[]'s

Rodolfo


tcp escreveu:

tcp

unread,
Sep 19, 2008, 2:43:53 PM9/19/08
to Django users
Your reply doesn't make sense to me. It is not WINDOWS looking for
the .py file, it is the Python interpreter. In any case, I have tried
that to prove that it is not the solution. Here is the proof:

C:\python\projects\iFriends>python django-admin.py help
python: can't open file 'django-admin.py': [Errno 2] No such file or
directory

C:\python\projects\iFriends>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\java
\jdk1.6.0_07\bin;
c:\python25;C:\Program Files\PuTTY;C:\python\Django-1.0\django\bin

C:\python\projects\iFriends>echo %PYTHONPATH%
c:\python\Django-1.0\django\bin

C:\python\projects\iFriends>dir C:\python\Django-1.0\django\bin
Volume in drive C has no label.
Volume Serial Number is 9C4E-C9AE

Directory of C:\python\Django-1.0\django\bin

09/19/2008 07:36 AM <DIR> .
09/19/2008 07:36 AM <DIR> ..
07/06/2008 02:39 AM 326 compile-messages.py
07/06/2008 02:39 AM 257 daily_cleanup.py
12/30/2006 02:25 AM 128 django-admin.py
07/06/2008 02:39 AM 323 make-messages.py
09/19/2008 07:36 AM <DIR> profiling
12/30/2006 02:25 AM 900 unique-messages.py
07/12/2005 09:25 PM 0 __init__.py
6 File(s) 1,934 bytes
3 Dir(s) 122,976,169,984 bytes free

Karen Tracey

unread,
Sep 19, 2008, 2:45:47 PM9/19/08
to django...@googlegroups.com
PYTHONPATH is used for imports.  For locating the initial .py file to start running, it has to be in your Windows PATH, just like any other executable.  Also I think you need to drop the 'python'  from the front of the command so that the Windows path search will actually happen.  I believe python.exe will just try to open whatever is specified in its first argument, and not search the Windows PATH. 

If you drop the python from the beginning then Windows will take care of searching PATH for the file, and then invoke python.exe to run the command (since the Python install has set up an association from the .py extension to the python.exe executable).

Karen

tcp

unread,
Sep 19, 2008, 2:49:03 PM9/19/08
to Django users
Ok. Now the link to the PATH makes more sense to me. I will try again
by associating .py files to Python.exe. Tom

On Sep 19, 10:45 am, "Karen Tracey" <kmtra...@gmail.com> wrote:

tcp

unread,
Sep 19, 2008, 2:53:40 PM9/19/08
to Django users
Karen and Rodolfo,

Thank you both for your quick answers. I have associated .py files
with Python.exe and then started Python by invoking the specific .py
file rather than directly invoking Python.exe and it works fine. Here
is the proof:

C:\>django-admin.py
Type 'django-admin.py help' for usage.

C:\>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\java
\jdk1.6.0_07\bin;
c:\python25;C:\Program Files\PuTTY;C:\python\Django-1.0\django\bin

Now I understand better that PYTHONPATH is only used for import and
not to load the initial module. Thanks.
Tom

mgag

unread,
Nov 8, 2008, 8:10:41 PM11/8/08
to Django users
And finally to get arguments to be passed correctly, one needs to
adjust the file association settings.

Open MyComputer, Tools->FolderOptions, FileTypes, find "PY" in the
list, select Advanced, select "open" and Edit. Change the Application
Used.. to

"C:\Python25\python.exe" "%1" %*

Change the python.exe path for your system as required.

Now at the DOS prompt,

c:>django-admin.py --version

should respond with the version.
Reply all
Reply to author
Forward
0 new messages