Rhubarb
Rhubarb

Reputation: 3993

No matter what I do, django-admin.py is not found, even though it's in my path

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?

Upvotes: 3

Views: 6644

Answers (5)

handlebar_
handlebar_

Reputation: 441

I realize this is old, but came across the same issue. On Windows, your path should include the following:

C:\Python27\;C:\Python27\Scripts

This is assuming python 2.7.3 is installed and django 1.4.3

Upvotes: 5

Santtu Pajukanta
Santtu Pajukanta

Reputation: 1381

This python command will search syspath for the django module in question:

python -m django.bin.django-admin

Upvotes: 4

Lionel
Lionel

Reputation: 108

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

Upvotes: 0

wisty
wisty

Reputation: 7061

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.

Upvotes: 5

Alex Martelli
Alex Martelli

Reputation: 881555

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!

Upvotes: 4

Related Questions