django-admin throws语法错误 - 配置问题我想 [英] django-admin throws syntax error - configuration issue I think
问题描述
Python 2.7.6(默认, 2010年11月10日,19:24:18)[win32
上的MSC v.1500 32位(Intel)]类型帮助,版权,信用或许可证了解更多信息。
>>> import django
>>>导入sys
>>>> print(django.VERSION)
(1,6,0,'final',0)
>>> django-admin.py startproject Nutana
文件< stdin>,第1行
django-admin.py startproject Nutana
^
SyntaxError:无效语法
> ;>>
我已经在site-packages目录中创建了一个.pth文件:
c:\python27\lib\site-packages\django
c:\python27\lib\site packages\django\bin
但这没有帮助。我也尝试过相对路径,而斜杠也是这样。
我也从命令行中直接尝试:
Z:\Nutana GeophysicsXXX\Web_Django> python django-admin.py startproject Nutana
python:无法打开文件' django-admin.py':[Errno 2]没有这样的文件或目录
我哪里错了
django-admin.py startproject Nutana
应该在命令行中运行,而不是在django shell中运行。
如果第二种情况不起作用
- 如果您使用虚拟-env,你忘了激活它吗?
- 确保将
C:\Python27\Scripts
添加到路径,你不会面对这个问题。
I'm fairly green in Python and trying to get django working to build a simple website. I've installed Django 1.6 under Python 2.7.6 but can't get django-admin to run. According to the tutorial I should create a project as follows, but I get a syntax error:
Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> import sys
>>> print(django.VERSION)
(1, 6, 0, 'final', 0)
>>> django-admin.py startproject Nutana
File "<stdin>", line 1
django-admin.py startproject Nutana
^
SyntaxError: invalid syntax
>>>
I've created a .pth file in the site-packages directory with this:
c:\python27\lib\site-packages\django
c:\python27\lib\site-packages\django\bin
but that doesn't help. I've tried it with relative paths as well, and with the slashes going the other way.
I've also tried straight from the command line:
Z:\Nutana GeophysicsXXX\Web_Django>python django-admin.py startproject Nutana
python: can't open file 'django-admin.py': [Errno 2] No such file or directory
Where have I gone wrong??
django-admin.py startproject Nutana
should be run in the command line, and not in the django shell.
If the second case is not working
- If you are using a virtual-env, did you forget to activate it ?
- Make sure you add
C:\Python27\Scripts
to the path, and you would not face this issue.
这篇关于django-admin throws语法错误 - 配置问题我想的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!