如何修复'django.core.exceptions.ImproperlyConfigured:找不到GDAL库'

问题描述 投票:0回答:1

我正在尝试在django数据库中存储商店的位置,我试图安装geodjango的目的是给我上面的错误。

我已经安装蟒蛇PostgreSQL的奥斯格psycopg2还根据geodjango文档修改了环境变量

我尝试使用-http://www.gisinternals.com/query.html?content=filelist&file=release-1911-x64-gdal-2-2-3-mapserver-7-0-7.zip手动安装gdal通用核心组件

我的settings.py文件-

import os
if os.name == 'nt':
    import platform
    OSGEO4W = r"C:\OSGeo4W"
    if '64' in platform.architecture()[0]:
        OSGEO4W += "64"
    assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W
    os.environ['OSGEO4W_ROOT'] = OSGEO4W
    os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal"
    os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
    os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH']


INSTALLED_APPS = [
...
'django.contrib.gis',
]

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'services',
        'USER': '*******',
        'HOST': 'localhost',
        'PASSWORD': '******',
        'PORT': '5434',
    }

我跑步时

python manage.py check

它给我错误

django.core.exceptions.ImproperlyConfigured: Could not find the GDAL library (tried "gdal202", "gdal201", "gdal20", "gdal111", "gdal110", "gdal19"). Is GDAL installed? If it is, try setting GDAL_LIBRARY_PATH in your settings.

我已经将gdal库路径设置为gdal数据目录,但仍然无法使用。

请帮助解决上面的问题。

还建议是否还有其他方法可以在Django数据库中存储位置?

django python-3.x geodjango
1个回答
0
投票

也将gdal300添加到GDAL库中。从现在开始安装GDAL,您将获得gdal300目录中的OSGeo4w64/bin。接下来,您可能会得到一个错误:django.core.exceptions.ImproperlyConfigured: jsonfield dependency missing

有一个简单的解决方法。 pip install jsonfield

这应该有效。

© www.soinside.com 2019 - 2024. All rights reserved.