OSError when trying to pip install shapely inside docker container
<p>Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']</p>

<p>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. When the docker container tries to install shapely I get the above error.</p>

<p>RUN apt-get install libgeos-dev</p>

<p>was something I saw trying to search the issue but that returns unable to locate package libgeos-dev</p>

<p>summary:</p>

<p>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  <code>Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']</code></p>

<p>Steps to reproduce:</p>

<p>use docker-compose to build on</p>

<p>Docker-compose.yml: </p>

<pre><code>app:
        build: ${APP_REPO}
</code></pre>

<p>Dockerfile:</p>

<pre><code>FROM python:3.5.1-onbuild
</code></pre>

<p>Requirements.txt:</p>

<pre><code>shapely
</code></pre>

<p>(Simplified to attempt to isolate issues.)</p>

<p>I found a solution from: <a href="https://github.com/calendar42/docker-python-geos/blob/master/Dockerfile" rel="nofollow">https://github.com/calendar42/docker-python-geos/blob/master/Dockerfile</a></p>

<pre><code>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 &amp;&amp; make -j $PROCESSOR_COUNT &amp;&amp; make install
RUN ldconfig
WORKDIR /install-postgis
</code></pre>

<p>I copied this into my dockerfile before the line</p>

<pre><code>pip install requirements.txt
</code></pre>

<p>and the shapely install worked.</p>

<p>It stalls out doing the build occasionally but the main problem was solved.</p>

python docker-compose shapely geos