gpt4 book ai didi

c++ - AttributeError :/usr/lib/libgdal. so.1: undefined symbol :OGR_F_GetFieldAsInteger64 在 Docker 中安装时

转载 作者:行者123 更新时间:2023-12-02 09:57:05 27 4
gpt4 key购买 nike

使用 postgres db 在 docker 上安装 GeoDjango 时出错。

我对 docker 完全陌生,我正在 docker 上设置我的项目。我不知道,这个错误是关于 django 还是 postgres。

发现这个错误

AttributeError: /usr/lib/libgdal.so.1: undefined symbol: OGR_F_GetFieldAsInteger64 While installing in Docker



docker-compose.yml
version: '3'
services:
postgres:
restart: always
image: postgres:alpine
volumes:
- ./postgres_gis/gis_db:/home/dev/gis_db.sql
environment:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: Dev@mishra123
POSTGRES_DB: gis_db
expose:
- "5432"
web:
build: ./HomePage
restart: always
expose:
- "8000"
volumes:
- ./HomePage:/home/dev/app/HomePage
depends_on:
- postgres
environment:
- DEBUG=1

网络/Dockerfile
from python:3.6.2-slim
RUN groupadd dev && useradd -m -g dev -s /bin/bash dev
RUN echo "dev ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
RUN mkdir -p /home/dev/app/HomePage
RUN chown -R dev:dev /home/dev/app
RUN chmod -R +x+r+w /home/dev/app
WORKDIR /home/dev/app/HomePage
RUN apt-get update && apt-get -y upgrade
COPY requirements.txt /home/dev/app/HomePage
RUN apt-get install -y python3-dev python3-pip
RUN apt-get install -y libpq-dev
RUN apt-get install -y binutils libproj-dev gdal-bin
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
COPY ./docker-entrypoint.sh /
RUN chmod +x /docker-entrypoint.sh
USER dev
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["python", "manage.py", "runserver", "0.0.0.0:8000"]

web/docker-entrypoint.sh
#!/bin/sh
python manage.py makemigrations
python manage.py migrate
python manage.py runserver 0.0.0.0:8000

docker-compose ps :
root@BlackCat:/home/dev/Project-EX/django-PR# docker-compose up      
Starting django-pr_postgres_1 ... done
Starting django-pr_web_1 ... done
Attaching to django-pr_postgres_1, django-pr_web_1
postgres_1 | 2019-12-12 16:34:43.907 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
postgres_1 | 2019-12-12 16:34:43.908 UTC [1] LOG: listening on IPv6 address "::", port 5432
postgres_1 | 2019-12-12 16:34:44.099 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
postgres_1 | 2019-12-12 16:34:44.672 UTC [18] LOG: database system was shut down at 2019-12-11 18:45:45 UTC
postgres_1 | 2019-12-12 16:34:44.912 UTC [1] LOG: database system is ready to accept connections
web_1 | Traceback (most recent call last):
web_1 | File "manage.py", line 22, in <module>
web_1 | execute_from_command_line(sys.argv)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
web_1 | utility.execute()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute
web_1 | django.setup()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
web_1 | apps.populate(settings.INSTALLED_APPS)
web_1 | File "/usr/local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
web_1 | app_config.import_models()
web_1 | File "/usr/local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
web_1 | self.models_module = import_module(models_module_name)
web_1 | File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
web_1 | return _bootstrap._gcd_import(name[level:], package,
web_1 | func = self.__getitem__(name)
web_1 | File "/usr/local/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
web_1 | func = self._FuncPtr((name_or_ordinal, self))
web_1 | AttributeError: /usr/lib/libgdal.so.1: undefined symbol: OGR_F_GetFieldAsInteger64
web_1 | Watching for file changes with StatReloader

最佳答案

您遇到的问题是您的 GDAL 版本太旧。您的 Dockerfile 建立在 python:3.6.2-slim 之上,该代码基于 Debian Jessie,并安装 gdal 版本 1.10.1OGR_F_GetFieldAsInteger64 变量是 introduced in v. 2.0.0

根据 debian.org 上的 GDAL package page,您需要更新版本的 Debian(stretch、buster、bullseye 都可以)。因此,我建议您更改 Dockerfile 以使用 python:3.8.0-slim-buster 或更新版本。请查看 hub.docker.com python 页面了解更多信息

此外,如评论中所述,您的 Dockerfile 应该只有 CMDENTRYPOINT 之一,但不能同时具有。由于您的 entrypoint.shCMD 的功能相同,因此我只需删除 CMD 并坚持使用 ENTRYPOINT
披露:我为 EnterpriseDB (EDB) 工作

关于c++ - AttributeError :/usr/lib/libgdal. so.1: undefined symbol :OGR_F_GetFieldAsInteger64 在 Docker 中安装时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59309687/

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