[英]OSError when trying to pip install shapely inside docker container
找不到库geos_c或加载其任何变体['libgeos_c.so.1','libgeos_c.so']
使用python:3.5.1映像,我正在尝试运行一个容器,该容器除其他外还将其安装在requirements.txt中。 当Docker容器尝试正确安装时,出现上述错误。
运行apt-get install libgeos-dev
我看到的是尝试搜索问题的内容,但返回无法找到软件包libgeos-dev
摘要:
预期的条件:在require.txt文件中包含形状会导致在构建Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
容器时已形状正确地安装ins实际条件:在构建期间收到错误消息Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
重现步骤:
使用docker-compose进行构建
码头工人,compose.yml:
app:
build: ${APP_REPO}
Dockerfile:
FROM python:3.5.1-onbuild
Requirements.txt:
shapely
(简化为试图隔离问题。)
对于高山,只需运行以下Docker命令:
RUN apk add --no-cache \
gcc \
libc-dev \
geos-dev \
&& pip install shapely
这将以形状正确的方式安装,并具有与geo和C相关的所有适当依赖关系(对于高山形状)
我从以下位置找到了解决方案: https : //github.com/calendar42/docker-python-geos/blob/master/Dockerfile
ENV PYTHONUNBUFFERED 1
#### Install GEOS ####
# Inspired by: https://hub.docker.com/r/cactusbone/postgres-postgis-sfcgal/~/dockerfile/
ENV GEOS http://download.osgeo.org/geos/geos-3.5.0.tar.bz2
#TODO make PROCESSOR_COUNT dynamic
#built by docker.io, so reducing to 1. increase to match build server processor count as needed
ENV PROCESSOR_COUNT 1
WORKDIR /install-postgis
WORKDIR /install-postgis/geos
ADD $GEOS /install-postgis/geos.tar.bz2
RUN tar xf /install-postgis/geos.tar.bz2 -C /install-postgis/geos --strip-components=1
RUN ./configure && make -j $PROCESSOR_COUNT && make install
RUN ldconfig
WORKDIR /install-postgis
我在此行之前将其复制到我的dockerfile中
pip install requirements.txt
并顺利进行安装。
它偶尔会停止进行构建,但主要问题已解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.