需要 Microsoft Visual C++ 14.0,在 Windows Docker 上安装 pip 包

vis*_*sch 2 python windows docker

我希望能够安装 C 编译器,因为某些软件包没有我需要的轮子。Windows 上大量的 Visual Studio 构建工具中所需的确切工具需要大量挖掘,并且安装需要很长时间。

我见过一些导致此问题的错误(请随意将其他错误添加到此列表中!)

  • 库 mkl_rt、openblas、lapack 未找到,而...
  • 错误:需要 Microsoft Visual C++ 14.0(无法找到 vcvarsall.bat)

vis*_*sch 5

  1. 首先,您需要从https://visualstudio.microsoft.com/downloads#other下载 Visual Studio 构建工具
  2. 创建一个名为 win_docker_test 的文件夹
  3. 在win_docker_test中创建一个名为bin的文件夹(win_docker_test/bin)
  4. 将 Visual Studio 构建工具放在 bin/ 目录中,并将文件重命名为 vs_buildtools.exe
  5. 复制下面的 Docker 文件

Dockerfile

# escape=`
# See https://learn.microsoft.com/en-us/virtualization/windowscontainers/manage-docker/manage-windows-dockerfile#:~:text=CMD%20reference.-,Escape%20character,-In%20many%20cases for explaining the above
FROM python:3.8.14-windowsservercore
# List here https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-community?view=vs-2022&preserve-view=true. We may be able to prune this list slightly!

COPY bin bin

RUN start-process -wait -filepath bin/vs_buildtools.exe -ArgumentList '--quiet --wait --norestart --nocache --installPath C:\BuildTools `
  --add Microsoft.VisualStudio.ComponentGroup.VC.Tools.142.x86.x64 `
  --add Microsoft.VisualStudio.Component.Windows10SDK.19041 `
  --add Microsoft.VisualStudio.Component.Windows10SDK `
  --add Microsoft.VisualStudio.Component.VC.CoreIde `
  --add Microsoft.VisualStudio.Component.VC.CMake.Project `
  --add Microsoft.VisualStudio.Component.VC.14.29.16.11.CLI.Support `
  --add Microsoft.VisualStudio.ComponentGroup.UWP.VC.v142'
RUN python -m pip install --upgrade pip setuptools wheel
Run Code Online (Sandbox Code Playgroud)
  1. 进行任何您想要的调整,然后运行docker build .