Lovesuper
@Lovesuper
pyhon, java, swift программист

Как в Docker Alpine поставить python Shapely?

Есть образ python:3.7-alpine. При попытке поставить в него Shapely получаю следующую ошибку:
/home/just-auth # pip3 install shapely
Collecting shapely
  Downloading https://files.pythonhosted.org/packages/a2/fb/7a7af9ef7a35d16fa23b127abee272cfc483ca89029b73e92e93cdf36e6b/Shapely-1.6.4.post2.tar.gz (225kB)
     |████████████████████████████████| 235kB 641kB/s 
    ERROR: Command errored out with exit status 1:
     command: /usr/local/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-vj51jvsy/shapely/setup.py'"'"'; __file__='"'"'/tmp/pip-install-vj51jvsy/shapely/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-vj51jvsy/shapely/pip-egg-info
         cwd: /tmp/pip-install-vj51jvsy/shapely/
    Complete output (11 lines):
    Failed `CDLL(libgeos_c.so.1)`
    Failed `CDLL(libgeos_c.so)`
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-vj51jvsy/shapely/setup.py", line 80, in <module>
        from shapely._buildcfg import geos_version_string, geos_version, \
      File "/tmp/pip-install-vj51jvsy/shapely/shapely/_buildcfg.py", line 167, in <module>
        fallbacks=['libgeos_c.so.1', 'libgeos_c.so'])
      File "/tmp/pip-install-vj51jvsy/shapely/shapely/_buildcfg.py", line 161, in load_dll
        libname, fallbacks or []))
    OSError: Could not find library geos_c or load any of its variants ['libgeos_c.so.1', 'libgeos_c.so']
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.


Установленные либы: make, gcc, geos-dev, musl-dev

Если поможет, вот тестовый докерфайл:

FROM python:3.7-alpine

RUN ["mkdir", "/home/test"]
WORKDIR /home/test

RUN echo "mirror.leaseweb.com/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN ["apk", "add", "make", "gcc", "geos-dev", "musl-dev"]
RUN ["pip3", "install", "virtualenv", "--no-warn-script-location", "--disable-pip-version-check"]
RUN ["virtualenv", ".env", "--python=python3"]
RUN ["pip3", "install", "shapely"]

CMD ["/bin/sh"]
  • Вопрос задан
  • 459 просмотров
Решения вопроса 1
Lovesuper
@Lovesuper Автор вопроса
pyhon, java, swift программист
Нашлось решение.

FROM python:3.7-alpine

RUN ["mkdir", "/home/test"]
WORKDIR /home/test

RUN echo "mirror.leaseweb.com/alpine/edge/testing" >> /etc/apk/repositories
RUN echo "dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories
RUN apk add --virtual .build-deps \
--repository dl-cdn.alpinelinux.org/alpine/edge/testing \
--repository dl-cdn.alpinelinux.org/alpine/edge/main \
gcc libc-dev geos-dev geos && \
runDeps="$(scanelf --needed --nobanner --recursive /usr/local \
| awk '{ gsub(/,/, "\nso:", $2); print "so:" $2 }' \
| xargs -r apk info --installed \
| sort -u)" && \
apk add --virtual .rundeps $runDeps
RUN ["pip", "install", "shapely"]

CMD ["/bin/sh"]
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы