interpretml / interpret

Fit interpretable models. Explain blackbox machine learning.
https://interpret.ml/docs
MIT License
6.22k stars 726 forks source link

Install fails due to Microsoft Visual C++ 14.0 dependency #132

Closed charleswm closed 3 years ago

charleswm commented 4 years ago

I created a new conda environment with python 3.7, pandas and jupyter.

Then i activated the environment and ran pip install interpret per the install instructions.

Unfortunately, it failed while building shap, seemingly due to not having visual studio build tools installed error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/ Did I skip a step here?

Are there any plans for packaging this as a conda package so that it can handle dependencies like this so that the user doesn't have to do additional installs and configuration beyond running "conda install interpret" or "pip install interpret"?

Also, do I need to install visual studio to use this library? or just C++14. It's not clear from the error message what's going on here and when I go to the build tools site it prompts me to install a ton of stuff.

Thanks!

Failed to build shap
Installing collected packages: greenlet, zope.event, zope.interface, pycparser, cffi, gevent, dash-table, click, itsdangerous, Werkzeug, Flask, brotli, flask-compress, retrying, plotly, dash-renderer, dash-core-components, dash-html-components, future, dash, dash-cytoscape, urllib3, chardet, idna, requests, psutil, joblib, cycler, kiwisolver, pyparsing, matplotlib, scipy, tqdm, pillow, threadpoolctl, scikit-learn, imageio, PyWavelets, tifffile, networkx, scikit-image, lime, SALib, dill, shap, treeinterpreter, interpret-core, interpret
    Running setup.py install for shap ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\charleswm\AppData\Local\Continuum\miniconda3\envs\interpret-demo\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\charleswm\\AppData\\Local\\Temp\\pip-install-osv0fkp_\\shap\\setup.py'"'"'; __file__='"'"'C:\\Users\\charleswm\\AppData\\Local\\Temp\\pip-install-osv0fkp_\\shap\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\charleswm\AppData\Local\Temp\pip-record-er9n9syn\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\charleswm\AppData\Local\Continuum\miniconda3\envs\interpret-demo\Include\shap'
         cwd: C:\Users\charleswm\AppData\Local\Temp\pip-install-osv0fkp_\shap\
    Complete output (67 lines):
    running install
    running build
    running build_py
    creating build
    creating build\lib.win-amd64-3.7
    creating build\lib.win-amd64-3.7\shap
    copying shap\common.py -> build\lib.win-amd64-3.7\shap
    copying shap\datasets.py -> build\lib.win-amd64-3.7\shap
    copying shap\__init__.py -> build\lib.win-amd64-3.7\shap
    creating build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\additive.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\bruteforce.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\explainer.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\gradient.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\kernel.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\linear.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\mimic.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\partition.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\permutation.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\pytree.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\sampling.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\tf_utils.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\tree.py -> build\lib.win-amd64-3.7\shap\explainers
    copying shap\explainers\__init__.py -> build\lib.win-amd64-3.7\shap\explainers
    creating build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\coefficent.py -> build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\lime.py -> build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\maple.py -> build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\random.py -> build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\treegain.py -> build\lib.win-amd64-3.7\shap\explainers\other
    copying shap\explainers\other\__init__.py -> build\lib.win-amd64-3.7\shap\explainers\other
    creating build\lib.win-amd64-3.7\shap\explainers\deep
    copying shap\explainers\deep\deep_pytorch.py -> build\lib.win-amd64-3.7\shap\explainers\deep
    copying shap\explainers\deep\deep_tf.py -> build\lib.win-amd64-3.7\shap\explainers\deep
    copying shap\explainers\deep\__init__.py -> build\lib.win-amd64-3.7\shap\explainers\deep
    creating build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\bar.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\colorconv.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\colors.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\decision.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\dependence.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\embedding.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\force.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\force_matplotlib.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\image.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\monitoring.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\partial_dependence.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\summary.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\text.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\waterfall.py -> build\lib.win-amd64-3.7\shap\plots
    copying shap\plots\__init__.py -> build\lib.win-amd64-3.7\shap\plots
    creating build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\experiments.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\measures.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\methods.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\metrics.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\models.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\plots.py -> build\lib.win-amd64-3.7\shap\benchmark
    copying shap\benchmark\__init__.py -> build\lib.win-amd64-3.7\shap\benchmark
    creating build\lib.win-amd64-3.7\shap\plots\resources
    copying shap\plots\resources\bundle.js -> build\lib.win-amd64-3.7\shap\plots\resources
    copying shap\plots\resources\logoSmallGray.png -> build\lib.win-amd64-3.7\shap\plots\resources
    copying shap\tree_shap.h -> build\lib.win-amd64-3.7\shap
    running build_ext
    numpy.get_include() C:\Users\charleswm\AppData\Local\Continuum\miniconda3\envs\interpret-demo\lib\site-packages\numpy\core\include
    building 'shap._cext' extension
    error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\charleswm\AppData\Local\Continuum\miniconda3\envs\interpret-demo\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\charleswm\\AppData\\Local\\Temp\\pip-install-osv0fkp_\\shap\\setup.py'"'"'; __file__='"'"'C:\\Users\\charleswm\\AppData\\Local\\Temp\\pip-install-osv0fkp_\\shap\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\charleswm\AppData\Local\Temp\pip-record-er9n9syn\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\charleswm\AppData\Local\Continuum\miniconda3\envs\interpret-demo\Include\shap' Check the logs for full command output.
interpret-ml commented 4 years ago

Hi @charleswm ,

Thanks for reporting this. The latest versions of SHAP now include pre-built wheels for Windows, so there shouldn't be a Microsoft Visual C++ requirement.

Can you try installing/upgrading SHAP by itself, and then installing interpret?

pip install -U shap
pip install interpret

Thanks! -InterpretML Team

charleswm commented 4 years ago

pip install shap fails for the same reason. I didn't notice this on my primary machine because I already have the C++ libraries, but seem to be running into this issue on a machine that doesn't already have this.

Any suggestions?

interpret-ml commented 4 years ago

Hi @charleswm -- Can you confirm that you included the "-U" (to upgrade) in the command above, so:

pip install -U shap

-InterpretML Team

charleswm commented 4 years ago

Yes that's what I ran. Sorry for the ambiguity.

interpret-ml commented 4 years ago

Hi @charleswm,

If your primary goal is to try the non-Shap features of the package, you can optionally avoid the Shap dependency by running:

pip install interpret-core[required,ebm,plotly,dash]

-InterpretML team

charleswm commented 4 years ago

Thanks for the response. This worked as a temporary fix so I can use ebm, but in general I do use SHAP.

Any idea if there's a more permanent solution?

mcheedle commented 4 years ago

FWIW, I'm having the same issue. I was able to install shap==0.34.0 and have it work.

interpret-ml commented 4 years ago

Hi @charleswm and @mcheedle ,

Looks like the Python 3.7 wheel wasn't included in the latest PyPi release of SHAP. Scott's tracking the issue here: https://github.com/slundberg/shap/issues/1093 , and it looks like there's an open PR to handle this for Python 3.7+ here: https://github.com/slundberg/shap/pull/1354. We'll leave this issue open until there's a fix pushed in SHAP for future reference. For now, a workaround is to pin to shap 0.34 (pip install shap==0.34) as suggested by @mcheedle, or by having Visual Studio (in Windows) or gcc (in Mac OS/Linux) installed on your machines.

Thanks, -InterpretML Team

philip-khor commented 4 years ago

Another workaround may be to install shap from conda-forge before installing interpret from pip

mcheedle commented 4 years ago

Thanks @philip-khor, was able to install using conda conda install -c conda-forge shap

interpret-ml commented 3 years ago

An upstream fix in SHAP should have resolved this issue, as wheels for Windows are now included in SHAP 0.36.

-InterpretML team