Django导入错误点

时间:2014-07-28 17:50:24

标签: django gis geospatial

我正在研究gis项目,我收到导入错误: 来自django.contrib.gis.goes import Point

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000002D11840>
Traceback (most recent call last):
  File "C:\Python33\lib\site-packages\django\utils\autoreload.py", line 93, in wrapper
    fn(*args, **kwargs)
  File "C:\Python33\lib\site-packages\django\core\management\commands\runserver.py", line 101, in inner_run
    self.validate(display_num_errors=True)
  File "C:\Python33\lib\site-packages\django\core\management\base.py", line 310, in validate
    num_errors = get_validation_errors(s, app)
  File "C:\Python33\lib\site-packages\django\core\management\validation.py", line 34, in get_validation_errors
    for (app_name, error) in get_app_errors().items():
  File "C:\Python33\lib\site-packages\django\db\models\loading.py", line 196, in get_app_errors
    self._populate()
  File "C:\Python33\lib\site-packages\django\db\models\loading.py", line 78, in _populate
    self.load_app(app_name)
  File "C:\Python33\lib\site-packages\django\db\models\loading.py", line 99, in load_app
    models = import_module('%s.models' % app_name)
  File "C:\Python33\lib\importlib\__init__.py", line 88, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1577, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1558, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1525, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
  File "<frozen importlib._bootstrap>", line 1023, in load_module
  File "<frozen importlib._bootstrap>", line 1004, in load_module
  File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
  File "<frozen importlib._bootstrap>", line 869, in _load_module
  File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
  File "C:\Users\raut_s\PycharmProjects\Prototype\webMap\models.py", line 2, in <module>
    from django.contrib.gis.geos import Point
ImportError: cannot import name Point

我有django 1.6.5。 Python是3.3

4 个答案:

答案 0 :(得分:5)

在命令行上尝试此操作

sudo apt-get install libgeos-dev

答案 1 :(得分:1)

在Mac OS中:

brew install libgeoip

答案 2 :(得分:1)

如果查看django / contrib / gis / geos / init .py,您可以看到Point对象仅在HAS_GEOS为True时可用,这取决于导入:

import com.google.common.eventbus.Subscribe;

所以修复它的原因是确保安装了所有地理空间依赖项:

import org.greenrobot.eventbus.Subscribe;

(根据https://docs.djangoproject.com/en/1.7/ref/contrib/gis/install/geolibs/#geospatial-libs

答案 3 :(得分:0)

方法1: 我通过安装libgeos和libgeos-dev

解决了这个问题
sudo apt-get install libgeos-dev