如何减少;python…PATH…django-admin.py startproject myprojname“;至;django-admin.py startproject myprojname“;?
更新:见底部如何减少;python…PATH…django-admin.py startproject myprojname“;至;django-admin.py startproject myprojname“;?,python,django,python-3.x,Python,Django,Python 3.x,更新:见底部 Django教程的第二部分指导您创建一个新项目,如下所示 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\p
Django教程的第二部分指导您创建一个新项目,如下所示
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\u 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
我证实了这两个
C:\applications\programming\python_341\
C:\applications\programming\python_341\Scripts
位于路径中
有没有关于如何降低成本的想法
python C:\applications\programming\python\u 341\Lib\site packages\django\bin\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\;
正如我所说,我完全把它评论掉了
C:\applications\programming\python_341\Scripts\django-admin.py
并补充说
import sys; print(sys.version, sys.executable)
到顶端。下面是运行的结果
django-admin.py startproject mysite2
再次:
django-admin.py启动项目mysite3('2.4.5(#11909年12月15日,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\u 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
用法:django-admin.py子命令[options][args]
选项:
-v冗长,--VERBOSITY=冗长
冗长程度;0=最小输出,1=正常输出,
2=详细输出,3=非常详细的输出
--设置=设置设置模块的Python路径,例如。
“myproject.settings.main”。如果未提供,则
DJANGO_设置_模块环境变量将为
习惯于
--pythonpath=pythonpath
要添加到Python路径的目录,例如。
“/home/djangoprojects/myproject”。
--异常时的回溯提升
--版本显示程序的版本号并退出
-h、 --帮助显示此帮助消息并退出
键入“django-admin.py help”以获取特定子命令的帮助。
可用子命令:
[django]
检查
清理
编译消息
createcachetable
dbshell
扩散设置
转储数据
脸红
检查数据库
加载数据
制造信息
runfcgi
运行服务器
壳
sql
sqlall
sqlclear
sqlcustom
sqldropindexes
sqlflush
sqlindexes
sqlinitialdata
sqlsequencereset
startapp
启动项目
同步数据库
测验
测试服务器
验证
我猜将*.py
关联到python.exe
,至少通过资源管理器这样做是一个错误
有什么想法吗?其他建议都是有效的。检查路径,同时检查用户和系统路径变量。一旦你确定只剩下正确的,再试一次 现在,一个稍微不同的方法。有时,一个软件需要有多个版本(包括python)。这就是为什么强烈建议使用virtualenv(和virtualenvwrapper)隔离python环境。
使用virtualenv,您可以安装代码所需的python版本,而不会与系统上的其他python版本发生冲突。Python3附带了virtualenv,但您可以阅读有关virtualenv和virutalenvwrapper的更多信息。看来您的
路径中仍然有一条旧python。你能提供整个路径吗?@Humdinger是的。事实证明,路径中有两个不同版本的python。现在就处理它。将在我完成时更新。@Humdinger:更新了问题帖子。还有一个问题,希望不会太多,可能还是路径问题。“如果django admin仅显示帮助文本,而不管给出了什么参数,则Windows中的文件关联可能有问题。请检查路径中是否设置了多个用于运行Python脚本的环境变量。这通常在安装了多个Python版本时发生。”from@Humdinger:Followup:
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