我有一个基于 alpine
的 Docker 文件,它使用conda
安装了几个软件包。最后使用pip
安装pydrill
,因为没有conda
的安装程序。
from jcrist/alpine-dask
RUN /opt/conda/bin/conda update -n base -c defaults conda -y
RUN /opt/conda/bin/conda update dask
RUN /opt/conda/bin/conda install -c conda-forge dask-ml
RUN /opt/conda/bin/conda install scikit-learn -y
RUN /opt/conda/bin/conda install flask -y
RUN /opt/conda/bin/conda install waitress -y
RUN /opt/conda/bin/conda install gunicorn -y
RUN /opt/conda/bin/conda install pytest -y
RUN /opt/conda/bin/conda install apscheduler -y
RUN /opt/conda/bin/conda install matplotlib -y
RUN /opt/conda/bin/conda install pyodbc -y
USER root
RUN apk update
RUN apk add py-pip
RUN pip install pydrill
当我构建Docker镜像时,一切正常。但是当我运行容器后,命令行会启动gunicorn
,但是它会失败并显示以下消息:
File "/code/app/service/cm/exec/run_drill.py", line 1, in <module>
from pydrill.client import PyDrill
ModuleNotFoundError: No module named 'pydrill'
这个 pip
安装是否正确?这是 Docker Compose 的配置文件:
version: "3.0"
services:
web:
image: img-dask
volumes:
- vol_py_code:/code
- vol_dask_data:/data
- vol_dask_model:/model
ports:
- "5000:5000"
working_dir: /code
environment:
- app.config=/code/conf/py.app.json
- common.config=/code/conf/py.common.json
entrypoint:
- /opt/conda/bin/gunicorn
command:
- -b 0.0.0.0:5000
- --reload
- app.frontend.app:app
scheduler:
image: img-dask
ports:
- "8787:8787"
- "8786:8786"
entrypoint:
- /opt/conda/bin/dask-scheduler
worker:
image: img-dask
depends_on:
- scheduler
environment:
- PYTHONPATH=/code
- MODEL_PATH=/model/rfc_model.pkl
- PREPROCESSING_PATH=/model/data_columns.pkl
- SCHEDULER_ADDRESS=scheduler
- SCHEDULER_PORT=8786
volumes:
- vol_py_code:/code
- vol_dask_data:/data
- vol_dask_model:/model
entrypoint:
- /opt/conda/bin/dask-worker
command:
- scheduler:8786
volumes:
vol_py_code:
name: vol_py_code
vol_dask_data:
name: vol_dask_data
vol_dask_model:
name: vol_dask_model
更新
如果我在容器内运行命令行,则可以看到已安装 pydrill,但我的代码无法识别该库。
/code/conf # pip3 list
Package Version
---------- ---------
certifi 2020.12.5
chardet 4.0.0
idna 2.10
pip 18.1
pydrill 0.3.4
requests 2.25.1
setuptools 40.6.2
urllib3 1.26.4
You are using pip version 18.1, however version 21.1.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/opt/conda/bin/pip install pydrill
而不是pip install pydrill
吗? - Elbek