AttributeError:/usr/lib/libgdal.so.1:未定义符号:OGR_F_GetFieldAsInteger64在Docker中安装时 [英] AttributeError: /usr/lib/libgdal.so.1: undefined symbol: OGR_F_GetFieldAsInteger64 While installing in Docker
问题描述
在使用postgres db的docker上安装GeoDjango时出错。
我对docker来说是个新手,我正在设置我的在docker上进行项目。我不知道,这是关于django还是postgres的错误。
I'm completely new to docker and i'm setting up my project on docker. I don't know, is this error is regarding django or postgres.
发现此错误
AttributeError:/usr/lib/libgdal.so .1:未定义符号:
OGR_F_GetFieldAsInteger64在Docker中安装时
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
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 $ c构建的$ c>基于Debian Jessie,并安装了
变量是在2.0.0版中引入的 gdal
版本 1.10.1
。 c> OGR_F_GetFieldAsInteger64
The problem you are encountering is that your version of GDAL is too old. Your Dockerfile
is built on python:3.6.2-slim
, which is based off Debian Jessie, and installs gdal
version 1.10.1
. The OGR_F_GetFieldAsInteger64
variable was introduced in v. 2.0.0
根据 GDAL软件包页面(位于debian.org),您需要Debian的更新版本(拉伸,克星,靶心都可以使用) 。因此,我建议您将 Dockerfile
更改为使用 python:3.8.0-slim-buster
或更高版本。请查看 hub.docker.com python 页面以获取更多信息
According to the GDAL package page at debian.org, you need a newer version of Debian (stretch, buster, bullseye will all work). As such, I would recommend that you change your Dockerfile
to use python:3.8.0-slim-buster
or newer. Please check the hub.docker.com python page for more information
此外,如评论中所述,您的 Dockerfile
应该仅具有 CMD
或 ENTRYPOINT
,但不能两者都选。由于您的 entrypoint.sh
可以完成 CMD
的工作,因此,我只删除 CMD
并坚持使用 ENTRYPOINT
Also, as mentioned in the comments, your Dockerfile
should only have one of CMD
or ENTRYPOINT
, but not both. Since your entrypoint.sh
does what CMD
does and more, I'd just remove CMD
and stick with ENTRYPOINT
披露:我为 EnterpriseDB(EDB)
这篇关于AttributeError:/usr/lib/libgdal.so.1:未定义符号:OGR_F_GetFieldAsInteger64在Docker中安装时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!