使用 docker 时无法打开共享对象文件

Cannot open shared object file when using docker

当我运行程序如下脚本时:

from hunspell import Hunspell

if __name__ == '__main__':
    h = Hunspell()
    print(h.spell('test'))

在本地机器上一切正常,但是当我构建 运行 docker 上的代码时,它会抛出以下异常:

    from hunspell import Hunspell
  File "/usr/local/lib/python3.6/site-packages/hunspell/__init__.py", line 3, in <module>
    from .hunspell import HunspellWrap as Hunspell
ImportError: libhunspell-1.3.so.0: cannot open shared object file: No such file or directory

我的 Dockerfile 是这样的:

FROM python:3

ADD main.py /

RUN pip install cyhunspell

CMD [ "python", "main.py" ]

Hunspell 使用我认为导致此类异常的 C++ 二进制文件。

有人知道如何解决这个问题吗? Dockerfile中的基础镜像是否需要使用Linux?

安装缺少的包:

FROM python:3

ADD main.py /
RUN apt-get update
RUN apt-get install -y libhunspell-1.3-0
RUN pip install cyhunspell

CMD [ "python", "main.py" ]