【问题标题】:geoDjango - ImportError: cannot import name SpatialBackendgeoDjango - ImportError:无法导入名称 SpatialBackend
【发布时间】:2011-12-02 16:00:07
【问题描述】:

我正在尝试使用 geoDjango 制作一个应用程序,但实际上我在运行它时遇到了一些问题。 当我执行“python manage.py syncdb”命令时,出现以下错误:

File "/media/datos/Proyectos/CualBondi/git/cualbondi/myapp/models.py", line 10, in <module>
from django.contrib.gis.db import models
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/__init__.py", line 5, in <module>
from django.contrib.gis.db.models.aggregates import *
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/aggregates.py", line 2, in <module>
from django.contrib.gis.db.models.sql import GeomField
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/sql/__init__.py", line 2, in <module>
from django.contrib.gis.db.models.sql.query import GeoQuery
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/sql/query.py", line 4, in <module>
from django.contrib.gis.db.models.fields import GeometryField
File "/usr/local/lib/python2.6/dist-packages/django/contrib/gis/db/models/fields/__init__.py", line 3, in <module>
from django.contrib.gis.db.backend import SpatialBackend, gqn
ImportError: cannot import name SpatialBackend

我在这里给你一些额外的信息:

  • Django 1.3.1
  • Python 2.6
  • Ubuntu 10.04
  • PostgreSQL 8.4.8

你有什么想法吗? 非常感谢!

【问题讨论】:

    标签: django geodjango importerror


    【解决方案1】:

    也许这有帮助,SpatialBackend 似乎已被弃用。阅读下面的警告。

    $ python manage.py shell
    Python 2.7.2+ (default, Oct  4 2011, 20:06:09) 
    [GCC 4.6.1] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    (InteractiveConsole)
    >>> from django.contrib.gis.db.backend import SpatialBackend, gqn
    /usr/lib/pymodules/python2.7/django/contrib/gis/db/backend/__init__.py:5: UserWarning: The `django.contrib.gis.db.backend` module was refactored and renamed to `django.contrib.gis.db.backends` in 1.2.  All functionality of `SpatialBackend` has been moved to the `ops` attribute of the spatial database backend.  A `SpatialBackend` alias is provided here for backwards-compatibility, but will be removed in 1.3.
      warn('The `django.contrib.gis.db.backend` module was refactored and '
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    ImportError: cannot import name gqn
    

    我在 django 1.3.0 上,似乎工作得很好,但只有那个警告。

    【讨论】:

      猜你喜欢
      • 2021-02-19
      • 1970-01-01
      • 2016-03-31
      • 2014-10-10
      • 2014-09-20
      • 2014-08-28
      • 2014-06-10
      • 2016-05-16
      • 2019-05-25
      相关资源
      最近更新 更多