3

我创建了一个 django (1.6.1) 项目并使用了 mongodb。当我运行python manage.py runserver 0.0.0.0:8000启动服务器时,它给了我以下错误

  File "D:\Python34\lib\importlib\__init__.py", line 129, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 2186, in _gcd_import
  File "<frozen importlib._bootstrap>", line 2169, in _find_and_load
  File "<frozen importlib._bootstrap>", line 2158, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 1209, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 1133, in _exec
  File "<frozen importlib._bootstrap>", line 1432, in exec_module
  File "<frozen importlib._bootstrap>", line 1537, in get_code
  File "<frozen importlib._bootstrap>", line 1497, in source_to_code
  File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
  File "D:\Python34\lib\site-packages\django_mongodb_engine\base.py", line 234
    raise ImproperlyConfigured, exc_info[1], exc_info[2]
                              ^
SyntaxError: invalid syntax

这个错误是什么意思?

4

1 回答 1

9

django-mongodb-engine不支持 Python 3.x。

类别

...

Programming Language :: Python :: 2.5
Programming Language :: Python :: 2.6
Programming Language :: Python :: 2.7

错误的含义:

Python 3.x 中更改了raise语句的语法。raise expression, expression, expression语法在 Python 3.x 中无效。

>>> raise ValueError, 'msg'
  File "<stdin>", line 1
    raise ValueError, 'msg'
                    ^
SyntaxError: invalid syntax

>>> raise ValueError('msg')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: msg
于 2014-01-24T05:50:01.770 回答