tags:

views:

199

answers:

3

I have added C:\Python26\Lib\site-packages\django\bin to my path, I have started a new cmd session in Windows 7, but when I try to do 'python django-admin.py ...' it says there is no file django-admin.py. When I type path, there is the full path to ...\django\bin. This is driving me nuts. Clearly it's there, but it's not working. Any suggestions?

+3  A: 

The python interpreter does not look everywhere on your path to find the script. It does look everywhere for imports, but not for scripts.

Try typing django-admin.py, just django-admin.py and not python django-admin.py, and it should work. Windows should find it on the path, then execute it as a python script.

OK,

If Windows doesn't run Python scripts (i.e. you have set your editor as the default python app), try: python -m django-admin or maybe python -m django-admin.py. The -m argument uses module mode, which checks the path.

wisty
+1 true (you could also type `python C:\Python26\Lib\site-packages\django\bin\django-admin.py`, but that's inconvenient)
David Zaslavsky
That's what I ended up doing, and yes it is not something I can lie with. The problem with just typing the script name is that Windows tried to launch the file with another app.
Rhubarb
+2  A: 

python -mdjango-admin looks like what you're looking for. -m tells Python to find a module on sys.path and run that module as "the main script" -- which seems exactly your goal!

Alex Martelli
+1  A: 

I had the same problem, and python -mdjango-admin works. but i had to define PYTHONHOME & PYTHONPATH first

Lionel