执行py -3.5 manage.py runserver时语法错误Django(1.10.1)

时间:2016-10-24 20:17:25

标签: python django

`

PS C:\Users\yoyoma207\Documents\UPriderfinder\up-ride-finder> py manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    execute_from_command_line(sys.argv)
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\ma
y", line 367, in execute_from_command_line
    utility.execute()
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\core\ma
y", line 316, in execute
    settings.INSTALLED_APPS
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\__
, in __getattr__
    self._setup(name)
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\__
, in _setup
    self._wrapped = Settings(settings_module)
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\django\conf\__
, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\importlib\__init__.py", line
ule
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "C:\Users\yoyoma207\Documents\UPriderfinder\up-ride-finder\config\settings\local.py", line 15,
    from .common import *  # noqa
  File "C:\Users\yoyoma207\Documents\UPriderfinder\up-ride-finder\config\settings\common.py", line 13
    import environ
  File "C:\Users\yoyoma207\AppData\Local\Programs\Python\Python35-32\lib\site-packages\environ.py", l
    raise ValueError, "No frame marked with %s." % fname
                    ^
SyntaxError: invalid syntax`

尝试使用Python 3.5启动一个新的Django项目,但我无法弄清楚是什么导致了这个问题,也许是因为我的environ.py存储在哪里?我真的不确定,所有的帮助都表示赞赏!

2 个答案:

答案 0 :(得分:22)

安装&#39; django-environ&#39;,而不是&#39;环境&#39;

答案 1 :(得分:0)

Python 3不再支持该语法。使用:

raise ValueError("No frame marked with %s." % fname)