UPDATED: See the bottom
The first step of the Django tutorial instructs you to create a new project like this
django-admin.py startproject mysite2
When I do that, it fails:
R:\jeffy\programming\sandbox\python\django_files\tutorial>django-admin.py startproject mysite
Traceback (most recent call last):
File "C:\applications\programming\python_341\Scripts\django-admin.py", line 2, in ?
from django.core import management
File "c:\applications\programming\python_341\Lib\site-packages\django\core\management\__init__.py", line 55
except ImportError as e:
^
SyntaxError: invalid syntax
I also tried
python django-admin.py startproject mysite2
Which also fails:
R:\jeffy\programming\sandbox\python\django_files\tutorial>python django-admin.py startproject mysite2
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
But when I do this, it works:
python C:\applications\programming\python_341\Lib\site-packages\django\bin\django-admin.py startproject mysite2
It gives no response, but the directory is created:
R:\jeffy\programming\sandbox\python\django_files\tutorial>dir mysite2
Volume in drive R is internal_files
Volume Serial Number is 9ADC-75EC
Directory of R:\jeffy\programming\sandbox\python\django_files\tutorial\mysite2
07/31 02:33 PM <DIR> .
07/31 02:33 PM <DIR> ..
07/31 02:33 PM 250 manage.py
07/31 02:33 PM <DIR> mysite2
1 File(s) 250 bytes
3 Dir(s) 208,804,356,096 bytes free
PYTHONPATH is equal to
c:\applications\programming\python_341\Lib\site-packages\
and I confirmed that both
C:\applications\programming\python_341\
C:\applications\programming\python_341\Scripts
are in PATH.
Any ideas on how to reduce
python C:\applications\programming\python_341\Lib\site-packages\django\bin\django-admin.py startproject mysite2
to
django-admin.py startproject mysite2
As in the Django tutorial?
Thank you.
UPDATE
Full path, line separated.
C:\applications\programming\python_341\;
C:\applications\programming\python_341\Scripts;
C:\applications\utilities\shell_utilities;
C:\applications\programming\;
.;
C:\Program Files\Common Files\ArcSoft\Bin;
C:\Program Files\Common Files\Microsoft Shared\Windows Live;
C:\Program Files\Windows Live\Shared;
C:\Windows;
C:\Windows\System32\Wbem;
C:\Windows\System32\WindowsPowerShell\v1.0\;
C:\Windows\system32;
C:\applications\audio\LilyPond\usr\bin;
C:\applications\internet\LinkChecker;
C:\applications\programming\DependencyFinder-1.2.1-beta4\bin;
C:\applications\programming\apache-ant-1.8.1\bin;
C:\applications\programming\apache-maven-3.1.1\bin;
C:\applications\programming\gradle-1.9\bin;
C:\applications\programming\jdk_7_51\bin;
C:\applications\programming\unix_utils\usr\local\wbin\;
C:\applications\video\quicktime\QTSystem\;
As suggested, I entirely commented out
C:\applications\programming\python_341\Scripts\django-admin.py
and added
import sys; print(sys.version, sys.executable)
to the top. Here is the result of running
django-admin.py startproject mysite2
again:
django-admin.py startproject mysite3 ('2.4.5 (#1, Dec 15 2009, 16:41:19) \n[GCC 4.1.1]', 'C:\\applications\\audio\\LilyPond\\usr\\bin\\python.exe')
And wouldn't you know it
C:\applications\audio\LilyPond\usr\bin
is part of the path.
After taking these steps
- uninstalling LilyPond, and eliminating it from the path
- re-installing Python 3.4.1 (although I'm not sure that was necessary)
- Associating ".py" files to open with C:\applications\programming\python_341\python.exe by default (I did this via right clicking
C:\applications\programming\python_341\Scripts\django-admin.pyin explorer, selecting "Open with...", and then browsing to python.exe and selecting it.)
this works:
python C:\applications\programming\python_341\Scripts\django-admin.py startproject mysite5
But both of these
django-admin.py startproject mysite5
C:\applications\programming\python_341\Scripts\django-admin.py startproject mysite5
fail with
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
--settings=SETTINGS The Python path to a settings module, e.g.
"myproject.settings.main". If this isn't provided, the
DJANGO_SETTINGS_MODULE environment variable will be
used.
--pythonpath=PYTHONPATH
A directory to add to the Python path, e.g.
"/home/djangoprojects/myproject".
--traceback Raise on exception
--version show program's version number and exit
-h, --help show this help message and exit
Type 'django-admin.py help <subcommand>' for help on a specific subcommand.
Available subcommands:
[django]
check
cleanup
compilemessages
createcachetable
dbshell
diffsettings
dumpdata
flush
inspectdb
loaddata
makemessages
runfcgi
runserver
shell
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlinitialdata
sqlsequencereset
startapp
startproject
syncdb
test
testserver
validate
I'm guessing associating *.py to python.exe, at least doing it via explorer, was a mistake.
Any ideas?
PATH. Can you provide the wholePATH? – Nick Humrich Jul 31 '14 at 18:50