我是django的新手,我开始浏览文档和民意调查教程。安装等没有问题,我已经到了创建和激活简单模型,但我现在尝试使用
调用Python shellpython manage.py shell
但我每次都会收到以下错误。
C:\Users\Owner\Desktop\Programming\Djang\mysite>python manage.py shell
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\python27\lib\site-packages\django\core\management\__init__.py", line
399, in execute_from_command_line
utility.execute()
File "C:\python27\lib\site-packages\django\core\management\__init__.py", line
392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\python27\lib\site-packages\django\core\management\base.py", line 242,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\python27\lib\site-packages\django\core\management\base.py", line 285,
in execute
output = self.handle(*args, **options)
File "C:\python27\lib\site-packages\django\core\management\base.py", line 415,
in handle
return self.handle_noargs(**options)
File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
line 81, in handle_noargs
self.run_shell(shell=interface)
File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
line 61, in run_shell
return getattr(self, shell)()
File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
line 44, in ipython
ip()
File "C:\python27\lib\site-packages\django\core\management\commands\shell.py",
line 37, in _ipython
from IPython import start_ipython
File "C:\python27\lib\site-packages\IPython\__init__.py", line 43, in <module>
from .config.loader import Config
File "C:\python27\lib\site-packages\IPython\config\__init__.py", line 16, in <
module>
from .application import *
File "C:\python27\lib\site-packages\IPython\config\application.py", line 29, i
n <module>
from IPython.external.decorator import decorator
File "C:\python27\lib\site-packages\IPython\external\decorator\__init__.py", l
ine 4, in <module>
from ._decorator import *
File "C:\python27\lib\site-packages\IPython\external\decorator\_decorator.py",
line 165
print('Error in generated code:', file=sys.stderr)
^
SyntaxError: invalid syntax
提前感谢您对此的任何帮助,因为虽然我在Python方面有一些经验,但我发现很难跟上上面的Traceback。
答案 0 :(得分:1)
您正在使用Python 2.7版本(而不是向后兼容)与Python 2.7版本。您需要为Python 2重新安装ipython
(在C:\python27
中)或升级到Python 3(并在ipython
中安装C:\python3
)
自1.6版以来,Django与Python 3正式兼容。