Home > OS >  Pip can't install shap because of missing c
Pip can't install shap because of missing c

Time:11-20

I'm trying to install the shap library using pip, on windows.

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/ "

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.

What else can I do ? Do I need to somehow tell pip where this is all installed ?

Thanks !

CodePudding user response:

You can use the compiler shipped with visual studio (not visual studio code), it's the simplest workaround that i know of.

From the python doc:

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

Visual Studio 2015 contains Visual C 14.0 compiler. Distutils will automatically detect the compiler and use it.

So you need to:

  1. install visual studio 2015 or latest
  2. install "Desktop development with C " from the workloads
  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.

CodePudding user response:

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.

It's a bit messy, but I only need shap for some experiments, so that'll do.

  • Related