gpt4 book ai didi

python - geodjango 中的 "cannot import name Polygon"

转载 作者:行者123 更新时间:2023-11-28 17:31:14 25 4
gpt4 key购买 nike

我正在尝试关注 this simple tutorial在我的网页上的传单 meap 上显示标记。但是,我收到以下错误:

from django.contrib.gis.geos.geometry import Polygon ImportError: cannot import name Polygon

由于这条语句 from djgeojson.views import GeoJSONLayerView 在我的 urls.py

我不确定如何解决这个问题,我已经为 geodjango 安装了所有必需的依赖项,但找不到名为“Polygon”的包..

这是完整的错误:

Unhandled exception in thread started by <function wrapper at 0x7fbe7c083050>
Traceback (most recent call last):
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 116, in inner_run
self.check(display_num_errors=True)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/management/base.py", line 426, in check
include_deployment_checks=include_deployment_checks,
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/checks/registry.py", line 75, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 10, in check_url_config
return check_resolver(resolver)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/checks/urls.py", line 19, in check_resolver
for pattern in resolver.url_patterns:
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 417, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/utils/functional.py", line 33, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 410, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/mohamed/Dropbox/newsparse/newsparser/src/newsparser/urls.py", line 22, in <module>
url(r'^', include('textnews.urls')),
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 52, in include
urlconf_module = import_module(urlconf_module)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/mohamed/Dropbox/newsparse/newsparser/src/textnews/urls.py", line 19, in <module>
from djgeojson.views import GeoJSONLayerView
File "/home/mohamed/Dropbox/newsparse/newsparser/local/lib/python2.7/site-packages/djgeojson/views.py", line 6, in <module>
from django.contrib.gis.geos.geometry import Polygon
ImportError: cannot import name Polygon

最佳答案

Django 1.9 的导入似乎中断了 https://github.com/makinacorpus/django-geojson/issues/68

关于python - geodjango 中的 "cannot import name Polygon",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34208459/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com