更新: 请参见底部
Django教程的first step指示您创建一个像这样的新项目
django-admin.py startproject mysite2
当我这样做时,它失败了:
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
我也试过
python django-admin.py startproject mysite2
哪个也失败了:
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
但是当我这样做时,它起作用:
python C:\applications\programming\python_341\Lib\site-packages\django\bin\django-admin.py startproject mysite2
它没有响应,但创建了目录:
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
等于
c:\applications\programming\python_341\Lib\site-packages\
我确认了两者
C:\applications\programming\python_341\
C:\applications\programming\python_341\Scripts
位于PATH
。
有关如何减少的任何想法
python C:\applications\programming\python_341\Lib\site-packages\django\bin\django-admin.py startproject mysite2
到
django-admin.py startproject mysite2
与Django教程一样?
谢谢。
更新
完整路径,分隔行。
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\;
作为suggested,我完全注释掉了
C:\applications\programming\python_341\Scripts\django-admin.py
并添加了
import sys; print(sys.version, sys.executable)
到顶部。这是运行
的结果django-admin.py startproject mysite2
再次:
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')
你不知道吗
C:\applications\audio\LilyPond\usr\bin
是路径的一部分。
采取这些步骤后
C:\applications\programming\python_341\Scripts\django-admin.py
,选择“打开方式...”,然后浏览到python.exe并选择它。)这有效:
python C:\applications\programming\python_341\Scripts\django-admin.py startproject mysite5
但这两个
django-admin.py startproject mysite5
C:\applications\programming\python_341\Scripts\django-admin.py startproject mysite5
失败
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
我猜测将*.py
关联到python.exe
,至少通过资源管理器进行关联,这是一个错误。
有什么想法吗?