将Conda Env迁移到Dockerfile时出现spaCy模型下载问题

时间:2020-05-09 11:40:40

标签: dockerfile conda spacy

我正在按照步骤https://pythonspeed.com/articles/activate-conda-dockerfile/#working 我创建环境的第一部分工作正常。 Dockerfile如下所示:

FROM continuumio/miniconda3
WORKDIR /app

# Create the environment:
COPY environment.yml .
RUN conda env create -f environment.yml

# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]

# Make sure the environment is activated:
RUN echo "Make sure flask is installed:"
RUN python -c "import spacy"

# The code to run when container is started:
COPY run.py .
ENTRYPOINT ["conda", "run", "-n", "myenv", "python", "run.py"]

我正在使用此基本图像并在新图像中下载模型:

FROM condatest:latest

WORKDIR /app
# Make RUN commands use the new environment:
SHELL ["conda", "run", "-n", "myenv", "/bin/bash", "-c"]

SHELL ["conda", "run", "-n", "myenv", "python", "-m", "spacy", "download", "en_core_web_sm"]
SHELL ["conda", "run", "-n", "myenv", "python", "-m", "spacy", "validate"]

COPY run.py .   
ENTRYPOINT ["conda", "run", "-n", "myenv", "python", "run.py"]

The validate step is also passing. But the code receives the error: `OSError: [E050] Can't find model 'en_core_web_sm'. It doesn't seem to be a shortcut link, a Python package or a valid path to a data directory.` Is including Conda in the docker image over complicating things?

0 个答案:

没有答案