微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

安装和配置 GeoDjango 的问题

如何解决安装和配置 GeoDjango 的问题

我正在按照以下教程创建基于地理位置的 Web 应用程序。尽管如此,我还是遇到了一些挑战,我一直在想办法解决这些问题。

参考 GeoDjango 教程:https://realpython.com/location-based-app-with-geodjango-tutorial/

按照说明(在上面提供的链接上) - 我已将 django.contrib.gis 作为我安装的应用程序的一部分。尽管如此,当这个包含到位时,Gunicorn 无法启动。

所以我猜这很可能是因为我需要安装其他相关的库才能让 GeoDjango 正常工作。

我在网上做了一些挖掘,发现了这个链接 - https://docs.djangoproject.com/en/3.2/ref/contrib/gis/install/geolibs/

似乎引用了需要安装的库。

我已经成功安装了 GEOSPROJ。虽然,最终要求是安装 GDAL

所以我找到了 GDAL pip3 install gdal 的相关安装命令,但是在 SSH 控制台中安装这个库时我收到以下错误

   Running setup.py install for gdal ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3.6 -u -c 'import io,os,sys,setuptools,tokenize; sys.argv[0] = '"'"'/tmp/pip-install-xjvcvnos/gdal_5ab038f0da3b44488d8b78e9cb9b461a/setup.py'"'"'; __file__='"'"'/tmp/pip-install-xjvcvnos/gdal_5ab038f0da3b44488d8b78e9cb9b461a/setup.py'"'"';f = getattr(tokenize,'"'"'open'"'"',open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"','"'"'\n'"'"');f.close();exec(compile(code,__file__,'"'"'exec'"'"'))' install --record /tmp/pip-record-p1c_7as0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/gdal
         cwd: /tmp/pip-install-xjvcvnos/gdal_5ab038f0da3b44488d8b78e9cb9b461a/
    Complete output (28 lines):
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-3.6
    copying gdal.py -> build/lib.linux-x86_64-3.6
    copying ogr.py -> build/lib.linux-x86_64-3.6
    copying osr.py -> build/lib.linux-x86_64-3.6
    copying gdalconst.py -> build/lib.linux-x86_64-3.6
    creating build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/__init__.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdal.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/ogr.py -> build/lib.linux-x86_64-3.6/osgeo
    copying osgeo/osr.py -> build/lib.linux-x86_64-3.6/osgeo
    running build_ext
    Could not run gdal-config!!!!
    building 'osgeo._gdal' extension
    creating build/temp.linux-x86_64-3.6
    creating build/temp.linux-x86_64-3.6/extensions
    gcc -pthread -Wno-unused-result -Wsign-compare -DDYNAMIC_ANNOTATIONS_ENABLED=1 -DNDEBUG -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -D_GNU_SOURCE -fPIC -fwrapv -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/include/python3.6m -I. -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.6/extensions/gdal_wrap.o
    extensions/gdal_wrap.cpp:2813:10: Fatal error: cpl_port.h: No such file or directory
     #include "cpl_port.h"
              ^~~~~~~~~~~~
    compilation terminated.
    error: command 'gcc' Failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3.6 -u -c 'import io,'"'"'exec'"'"'))' install --record /tmp/pip-record-p1c_7as0/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6m/gdal Check the logs for full command output.

我正在运行最新版本的 Django,并且在我的 CentOS 服务器上使用 pip 版本 21.1.1。

有人对我在这里可能出错的地方有任何想法或建议吗? :-)

谢谢!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。