Python 如何将OSMnx与Django一起使用?
我想创建一个应用程序来计算地图上给定点之间的路线。我正在使用Conda来管理我的环境。在我的venv中,我安装了Django和OSMnx。添加OSMnx后,服务器将不会运行。stacktrace相当长,以以下内容结束:Python 如何将OSMnx与Django一起使用?,python,django,conda,osmnx,Python,Django,Conda,Osmnx,我想创建一个应用程序来计算地图上给定点之间的路线。我正在使用Conda来管理我的环境。在我的venv中,我安装了Django和OSMnx。添加OSMnx后,服务器将不会运行。stacktrace相当长,以以下内容结束: with fiona._loading.add_gdal_dll_directories(): AttributeError: module 'fiona' has no attribute '_loading' 在我的Django项目中,我有一个名为planner的应
with fiona._loading.add_gdal_dll_directories():
AttributeError: module 'fiona' has no attribute '_loading'
在我的Django项目中,我有一个名为planner的应用程序,视图使用的是OSMnx(不确定该代码是否应该放在那里),它看起来如下所示:
from django.shortcuts import render
from django.http import HttpResponse, JsonResponse
import osmnx as ox
ox.config(use_cache=True, log_console=True)
# Create your views here.
def index(request):
# As for now it is ok to hardcode place and network type
warsaw_streets = ox.graph_from_place("Warsaw", network_type="drive")
return JsonResponse({})
我是Django的新手,我不知道我是否使用了错误的外部库,或者这个错误的目的是什么…您的OSMnx库可能有错误 您可以尝试:
您的OSMnx库可能存在此错误 您可以尝试:
我解决了!我第一次创建conda env并通过“conda install Django”安装Django,然后是osmnx“conda install osmnx”,但它不起作用。我试过其他方法:
这个解决方案对我有效。我解决了!我第一次创建conda env并通过“conda install Django”安装Django,然后是osmnx“conda install osmnx”,但它不起作用。我试过其他方法:
这个解决方案对我很有效。请发布完整的堆栈跟踪和有关如何安装OSMnx的完整详细信息。注意具体的安装。是的,谢谢!这是一个安装问题。我设法解决了这个问题,并发布了对我有用的答案。请发布完整的堆栈跟踪和有关如何安装OSMnx的完整详细信息。注意具体的安装。是的,谢谢!这是一个安装问题。我设法解决它,并张贴为MEOMNX工作的答案不直接使用菲奥娜。然而,它的依赖性,GeoPandas,所以这更有可能是安装问题。OSMNX不直接使用菲奥娜。但是,它的依赖项GeoPandas确实存在,因此这更可能是安装问题。