在Docker映像中导入模块和依赖项

时间:2019-06-16 21:54:07

标签: python docker dockerfile requirements.txt lightgbm

我已经成功构建了一个docker映像,将在其中运行lightgbm模型。

我运行容器没有问题。

当我开始运行包含以下内容的脚本时:import lightgbm as lgb

我知道这是依赖关系的问题,但是我不知道如何生成运行脚本所需的所有软件包。

出现以下错误:

`root@a3ea9bbe57e0:/physionet2019# python driver.py /Users/macbook/Desktop/Docker_test/input_directory /Users/macbook/Desktop/Docker_test/output_directory
Traceback (most recent call last):
  File "driver.py", line 5, in <module>
    from get_sepsis_score import *
  File "/physionet2019/get_sepsis_score.py", line 5, in <module>
    import lightgbm as lgb
  File "/usr/local/lib/python3.7/site-packages/lightgbm/__init__.py", line 8, in <module>
    from .basic import Booster, Dataset
  File "/usr/local/lib/python3.7/site-packages/lightgbm/basic.py", line 33, in <module>
    _LIB = _load_lib()
  File "/usr/local/lib/python3.7/site-packages/lightgbm/basic.py", line 28, in _load_lib
    lib = ctypes.cdll.LoadLibrary(lib_path[0])
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 434, in LoadLibrary
    return self._dlltype(name)
  File "/usr/local/lib/python3.7/ctypes/__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libgomp.so.1: cannot open shared object file: No such file or directory`

请问如何解决此问题?

其他信息:

我的require.txt是:

numpy==1.16.0
pandas==0.23.4
scipy==1.1.0
sklearn==0.0
tqdm==4.26.0
lightgbm==2.1.2 

Dockerfile:

FROM python:3.7.3-slim

## The MAINTAINER instruction sets the Author field of the generated images
MAINTAINER my.email@gmail.com
## DO NOT EDIT THESE 3 lines
RUN mkdir /physionet2019
COPY ./ /physionet2019
WORKDIR /physionet2019

## Install your dependencies here using apt-get etc.

## Do not edit if you have a requirements.txt
RUN pip install -r requirements.txt

0 个答案:

没有答案