I'm running Windows 8.1, Python 3.4.2, Django 1.7.
.py
files are associated with python.exe
.
Windows system path is:
C:\lots_of_paths;C:\Python34;C:\Python34\Lib\site-packages\Django-1.7.1-py3.4.egg\django\bin
(total of 531 characters)
PYTHONPATH variable in registry is:
C:\Python34\Lib;C:\Python34\DLLs;C:\Python34\Lib\site-packages\Django-1.7.1-py3.4.egg\django\bin
(total of 96 characters)
I pasted the Django path when setting this variable, to avoid typos. When I copy and paste from PYTHONPATH to notepad there is not a break in the line, so there appears to be no hidden carriage return.
I start cmd.exe
and work from the directory C:\projects.
When I enter python -c "import sys;print(sys.path)"
The result is:
['', 'C:\Python34\lib\site-packages\django-1.7.1-py3.4.egg', 'C:\WINDOWS\S YSTEM32\python34.zip', 'C:\Python34\DLLs', 'C:\Python34\lib', 'C:\Python34 ', 'C:\Python34\lib\site-packages']
\django\bin is being clipped from the path.
When I enter python django-admin.py startproject please_work
...it prints: python: can't open file 'django-admin.py': [Errno 2] No such file or directory
It appears that system path locates Python, but PYTHONPATH doesn't work, as expected.
When I type django-admin startproject saving_time
I get this:
Usage: django-admin.py subcommand [options] [args]
Options:
-v VERBOSITY, --verbosity=VERBOSITY
Verbosity level; 0=minimal output, 1=normal output,
2=verbose output, 3=very verbose output
(etc. etc. etc.)
...so it appears that django-admin.py
is found on the system path and ran via association with python.exe
, but the arguments are not passed. I get the same result when the .py suffix is included in the command as suggested in one answer below: django-admin.py startproject testproject
Typing python C:\Python34\Lib\site-packages\Django-1.7.1-py3.4.egg\django\bin\django-admin.py startproject wasting_time
functions properly, but it shouldn't be necessary, right?
Since you do have a command line solution that works why not create a batch file in
C:\Python34\Scripts
possibly called dj-admin.bat which includes either your full command with parameters, if this is the command that you do all of the time, or allows you to use parameters.By the way, as far as I know, when you type:
Python expects somefile.py to be either in the local directory or an absolute path it doesn't search PYTHON_PATH for it but if you type:
Python will look first in the current directory then on PYTHON_PATH.
The other possible source of your problem is having more than one django-admin on your path - if it is earlier in the path it will take precedence. On Unix/Linux systems there is a lovely command called
which
which will tell you which commands are being found.A python implementation of which is quite simple to do.