简体   繁体   English

Pip 由于缺少 c++ 无法安装 shap

[英]Pip can't install shap because of missing c++

I'm trying to install the shap library using pip, on windows.我正在尝试在 windows 上使用 pip 安装 shap 库。

I get the error "Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ "我收到错误“需要 Microsoft Visual C++ 14.0 或更高版本。使用“Microsoft C++ 构建工具”获取它: httpspp://visualstudio.microsoft/ “visual.com/visualstudio.

I have tried installing it, selecting the c++ build tools, c++ redist and windows sdk (and many other libs that looked like they could work), but it still won't work. I have tried installing it, selecting the c++ build tools, c++ redist and windows sdk (and many other libs that looked like they could work), but it still won't work.

I tried updating pip, setuptools and wheels, to no avail.我尝试更新 pip、setuptools 和 wheel,但无济于事。

What else can I do?我还可以做些什么? Do I need to somehow tell pip where this is all installed?我是否需要以某种方式告诉 pip 这全部安装在哪里?

Thanks !谢谢 !

You can use the compiler shipped with visual studio (not visual studio code), it's the simplest workaround that i know of.您可以使用 Visual Studio 附带的编译器(不是 Visual Studio 代码),这是我所知道的最简单的解决方法。

From the python doc :来自python 文档

Microsoft Visual C++ 14.0 with Visual Studio 2015 (x86, x64, ARM) Microsoft Visual C++ 14.0 与 Visual Studio 2015(x86、x64、ARM)

Visual Studio 2015 contains Visual C++ 14.0 compiler. Visual Studio 2015 包含 Visual C++ 14.0 编译器。 Distutils will automatically detect the compiler and use it. Distutils 会自动检测编译器并使用它。

So you need to:所以你需要:

  1. install visual studio 2015 or latest安装 Visual Studio 2015 或最新版本
  2. install "Desktop development with C++" from the workloads从工作负载安装“使用 C++ 进行桌面开发”
  3. it's done完成

With the compiler is instaled this way there is no need to configure your pip or anything, all libs that need c++ compilation will be usable.通过这种方式安装编译器,无需配置您的 pip 或任何东西,所有需要 c++ 编译的库都将可用。

Update: thank you for your answers.更新:感谢您的回答。 I was eventually able to figure out a workaround: I installed shap through conda instead of pip, I believe conda uses a precompiled version.我最终找到了一个解决方法:我通过 conda 而不是 pip 安装了 shap,我相信 conda 使用的是预编译版本。

It's a bit messy, but I only need shap for some experiments, so that'll do.这有点乱,但我只需要 shap 进行一些实验,这样就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM