首页 > 解决方案 > Windows Docker (Python) 中的 DLL 问题

问题描述

我在将代码加载到 Docker 容器中时遇到问题。

我的dockerfile如下:

 FROM python:3

USER ContainerAdministrator
RUN curl -fSLo vc_redist.x64.exe https://aka.ms/vs/16/release/vc_redist.x64.exe `
    && start /w vc_redist.x64.exe /install /quiet /norestart `
    && del vc_redist.x64.exe
RUN setx path "%path%;C:\Windows\SysWOW64"

ENV PYTHONUNBUFFERED 1
ENV PYTHONPATH="$PYTHONPATH:/DeepLearningController"
COPY DeepLearningController /
COPY requirements.txt /

RUN pip install --upgrade pip
RUN pip --no-cache-dir install -r requirements.txt
RUN pip --no-cache-dir install tensorflow==2.2.0

CMD [ "python", "./DeepLearningController"] 

当我运行此代码时,我遇到一个错误:

ImportError: Could not find the DLL(s) 'msvcp140.dll or msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" for your platform from this URL: https://support.microsoft.com/help/2977003/the-latest-supported-visual-c-downloads

如果我在 Docker 上使用 Linux 容器,同样的效果也很好。我的主机操作系统是 windows。

我尝试在 dockerfile 中添加 python 路径,但我不确定为什么这不起作用。任何建议都会很棒!

谢谢!

标签: pythondockerdockerfile

解决方案


推荐阅读