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 suggestio开发者_C百科ns?
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.
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
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!
This python command will search syspath for the django module in question:
python -m django.bin.django-admin
I had the same problem, and python -mdjango-admin works. but i had to define PYTHONHOME & PYTHONPATH first
精彩评论