使用django时在系统生成的文件上获取语法错误!如何解决?

时间:2017-08-05 22:19:34

标签: django syntax-error

当我使用命令

在我的django项目中设置一个超级用户时
$ python manage.py syncdb
  File "manage.py", line 14
    ) from exc
         ^
SyntaxError: invalid syntax

manage.py是系统生成的文件,但仍显示语法错误。 这是manage.py文件! -

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", 
"my_django15_project.settings")
   try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
        "available on your PYTHONPATH environment variable? Did you "
        "forget to activate a virtual environment?"
    ) from exc
execute_from_command_line(sys.argv)

请告诉一些解决方案!

1 个答案:

答案 0 :(得分:0)

Python 2.x中不支持from的{​​{1}}部分。请改用Python 3.x.