我在执行django-admin startproject newDjango作为invalide语法时遇到错误

时间:2018-09-02 06:40:54

标签: django python-3.x

(newDjango) C:\Python34\Scripts\newDjango>C:\Python34\Scripts\newDjango\Scripts\django-admin.exe startproject newDjango .
Traceback (most recent call last):
  File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
    "__main__", mod_spec)
  File "C:\Python34\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Python34\Scripts\newDjango\Scripts\django-admin.exe\__main__.py", line 5, in <module>
  File "c:\python34\scripts\newdjango\lib\site-packages\django\core\management\__init__.py", line 11, in <module>
    from django.conf import settings
  File "c:\python34\scripts\newdjango\lib\site-packages\django\conf\__init__.py", line 18, in <module>
    from django.utils.functional import LazyObject, empty
  File "c:\python34\scripts\newdjango\lib\site-packages\django\utils\functional.py", line 12
    return _curried_func(*args, *moreargs, **{**kwargs, **morekwargs})
                                ^
SyntaxError: invalid syntax

1 个答案:

答案 0 :(得分:1)

如果您使用的是python 3.4,请确保已安装Django 2.0。 使用python 3.4,Django 2.1x会引发上述错误。

运行命令以安装django: pip3 install Django==2.0.0

验证版本:

$ python -m django --version
2.0

$ python -V
Python 3.4.0

这应该可以解决您的问题。