首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >只在导入geemap包时才会发生Django中的循环导入错误

只在导入geemap包时才会发生Django中的循环导入错误
EN

Stack Overflow用户
提问于 2022-02-21 08:23:18
回答 1查看 42关注 0票数 0

我正在尝试使用geemap与django一起构建一个用于绘制卫星数据的web应用程序。我已经在django项目中安装了geemap包。我的项目名为CustomMaps,目录结构如下所示。在这里输入图像描述

我的CustomMaps.urls.py的代码如下

代码语言:javascript
复制
from django.contrib import admin
from django.urls import path
from django.conf.urls import include, url




urlpatterns = [
    path('admin/', admin.site.urls),
    path('plotmap/', include('PlotMap.urls')),
]

我的PlotMap.urls.py的代码如下

代码语言:javascript
复制
from django.urls import path
from django.conf.urls import include, url
from .views import hello



urlpatterns = [
    path('hello/', hello, name = 'hello'),
]

我的PlotMap.views.py如下所示

代码语言:javascript
复制
from django.http import HttpResponse
from django.shortcuts import render
import geemap as gm
#import pandas as pd

def hello(request):
   map = gm.Map()
   return render(request, "PlotMap/hello.html", { "m" : map})

但我在运行该项目时遇到了以下错误

代码语言:javascript
复制
Exception in thread django-main-thread:
Traceback (most recent call last):
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\urls\resolvers.py", 
line 604, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\HP\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 916, in _bootstrap_inner
    self.run()
  File "C:\Users\HP\AppData\Local\Programs\Python\Python36-32\lib\threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
    fn(*args, **kwargs)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
    self.check(display_num_errors=True)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\core\management\base.py", line 423, in check
    databases=databases,
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
    return check_resolver(resolver)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
    return check_method()
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\urls\resolvers.py", 
line 416, in check
    for pattern in self.url_patterns:
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\utils\functional.py", line 48, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\Internship\Django App\MyProject\lib\site-packages\django\urls\resolvers.py", 
line 611, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name)) from e
django.core.exceptions.ImproperlyConfigured: The included URLconf 'CustomMaps.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.

但是,如果我在像下面这样更改了views.py之后运行相同的代码,它就会运行得非常好。

代码语言:javascript
复制
from django.http import HttpResponse
from django.shortcuts import render
#import geemap as gm
#import pandas as pd

def hello(request):
   #map = gm.Map()
   return render(request, "PlotMap/hello.html", { })

我无法理解为什么我的“导入geemap”会导致CustomMaps.urls.py中的循环导入错误。我试着去寻找同样的东西,但到目前为止一直找不到任何东西。如果有人能帮帮我,我很快就能继续工作了,谢谢。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-02-23 07:44:38

实际上,我尝试安装了一个新版本的python(3.8),并下载了一个新版本的geemap(0.11.4)来解决这个问题。

但是,我仍然在挣扎如何在django模板中显示geemap.Map()实例,任何建议都会很有帮助。

我将为同样的问题发表一个新的问题。这里:如何在Django模板中显示geemap.Map()实例

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71203158

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档