简体   繁体   English

尝试在Docker容器内进行点状安装时出现OSError

[英]OSError when trying to pip install shapely inside docker container

Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'] 找不到库geos_c或加载其任何变体['libgeos_c.so.1','libgeos_c.so']

using the python:3.5.1 image I am trying to run a container that includes among other things it installs in requirements.txt shapely. 使用python:3.5.1映像,我正在尝试运行一个容器,该容器除其他外还将其安装在requirements.txt中。 When the docker container tries to install shapely I get the above error. 当Docker容器尝试正确安装时,出现上述错误。

RUN apt-get install libgeos-dev 运行apt-get install libgeos-dev

was something I saw trying to search the issue but that returns unable to locate package libgeos-dev 我看到的是尝试搜索问题的内容,但返回无法找到软件包libgeos-dev

summary: 摘要:

expected conditions: including shapely in the requirements.txt file results ins shapely being installed when the docker container is built actual conditions: An error message is recieved during build Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so'] 预期的条件:在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']

Steps to reproduce: 重现步骤:

use docker-compose to build on 使用docker-compose进行构建

Docker-compose.yml: 码头工人,compose.yml:

app:
        build: ${APP_REPO}

Dockerfile: Dockerfile:

FROM python:3.5.1-onbuild

Requirements.txt: Requirements.txt:

shapely

(Simplified to attempt to isolate issues.) (简化为试图隔离问题。)

For alpine, just run following Docker command: 对于高山,只需运行以下Docker命令:

RUN apk add --no-cache \
gcc \
libc-dev \
geos-dev \
&& pip install shapely

This will install shapely with all the proper dependencies for geo and C related dependencies for the shapely for alpine 这将以形状正确的方式安装,并具有与geo和C相关的所有适当依赖关系(对于高山形状)

I found a solution from: https://github.com/calendar42/docker-python-geos/blob/master/Dockerfile 我从以下位置找到了解决方案: 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

I copied this into my dockerfile before the line 我在此行之前将其复制到我的dockerfile中

pip install requirements.txt

and the shapely install worked. 并顺利进行安装。

It stalls out doing the build occasionally but the main problem was solved. 它偶尔会停止进行构建,但主要问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM