shap / shap

A game theoretic approach to explain the output of any machine learning model.
https://shap.readthedocs.io
MIT License
22.82k stars 3.29k forks source link

pip install shap fail #539

Closed lilly-chen closed 1 year ago

lilly-chen commented 5 years ago

Hi, I tried to install shap through anaconda and fail to do that, the error is pasted below, is there anything i can do to fix this... Thanks!

(py37) C:\Users\chenl>pip install shap Collecting shap Using cached https://files.pythonhosted.org/packages/30/b3/866b0101cbd1829844c35964af68c14ba522a5cce7a1e8d0f7937411d910/shap-0.28.5.tar.gz Requirement already satisfied: numpy in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (1.15.4) Requirement already satisfied: scipy in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (0.19.1) Requirement already satisfied: scikit-learn in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (0.19.2) Requirement already satisfied: matplotlib in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (2.0.2) Requirement already satisfied: pandas in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (0.20.3) Requirement already satisfied: tqdm in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (4.31.1) Requirement already satisfied: ipython in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (5.1.0) Requirement already satisfied: scikit-image in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from shap) (0.14.2) Requirement already satisfied: six>=1.10 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (1.10.0) Requirement already satisfied: python-dateutil in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (2.6.0) Requirement already satisfied: functools32 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (3.2.3.post2) Requirement already satisfied: pytz in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (2016.10) Requirement already satisfied: cycler>=0.10 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (0.10.0) Requirement already satisfied: pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=1.5.6 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from matplotlib->shap) (2.1.4) Requirement already satisfied: dask[array]>=1.0.0 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from scikit-image->shap) (1.1.5) Requirement already satisfied: pillow>=4.3.0 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from scikit-image->shap) (6.0.0) Requirement already satisfied: cloudpickle>=0.2.1 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from scikit-image->shap) (0.8.1) Requirement already satisfied: networkx>=1.8 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from scikit-image->shap) (2.2) Requirement already satisfied: PyWavelets>=0.4.0 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from scikit-image->shap) (1.0.2) Requirement already satisfied: toolz>=0.7.3; extra == "array" in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from dask[array]>=1.0.0->scikit-image->shap) (0.9.0) Requirement already satisfied: decorator>=4.3.0 in c:\users\chenl\anaconda3\envs\dand\lib\site-packages (from networkx>=1.8->scikit-image->shap) (4.4.0) Building wheels for collected packages: shap Running setup.py bdist_wheel for shap ... error Complete output from command c:\users\chenl\anaconda3\envs\dand\python.exe -u -c "import setuptools, tokenize;file='c:\users\chenl\appdata\local\temp\pip-install-den8yg\shap\setup.py';f=getattr(tokenize, 'open', open)(file);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, file, 'exec'))" bdist_wheel -d c:\users\chenl\appdata\local\temp\pip-wheel-nqy36z --python-tag cp27: c:\users\chenl\anaconda3\envs\dand\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running bdist_wheel running build running build_py creating build creating build\lib.win-amd64-2.7 creating build\lib.win-amd64-2.7\shap copying shap\common.py -> build\lib.win-amd64-2.7\shap copying shap\datasets.py -> build\lib.win-amd64-2.7\shap copying shap__init.py -> build\lib.win-amd64-2.7\shap creating build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\explainer.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\gradient.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\kernel.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\linear.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\mimic.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\pytree.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\sampling.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\tree.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers__init.py -> build\lib.win-amd64-2.7\shap\explainers creating build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\coefficent.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\lime.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\random.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\treegain.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\init.py -> build\lib.win-amd64-2.7\shap\explainers\other creating build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\deep_pytorch.py -> build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\deep_tf.py -> build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\init__.py -> build\lib.win-amd64-2.7\shap\explainers\deep creating build\lib.win-amd64-2.7\shap\plots copying shap\plots\colors.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\dependence.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\embedding.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\force.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\force_matplotlib.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\image.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\monitoring.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\summary.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\init.py -> build\lib.win-amd64-2.7\shap\plots creating build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\experiments.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\measures.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\methods.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\metrics.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\models.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\plots.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\init__.py -> build\lib.win-amd64-2.7\shap\benchmark creating build\lib.win-amd64-2.7\shap\plots\resources copying shap\plots\resources\bundle.js -> build\lib.win-amd64-2.7\shap\plots\resources copying shap\plots\resources\logoSmallGray.png -> build\lib.win-amd64-2.7\shap\plots\resources copying shap\tree_shap.h -> build\lib.win-amd64-2.7\shap running build_ext ('numpy.get_include()', 'c:\users\chenl\anaconda3\envs\dand\lib\site-packages\numpy\core\include') building 'shap._cext' extension error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27


Failed building wheel for shap Running setup.py clean for shap Failed to build shap Installing collected packages: shap Running setup.py install for shap ... error Complete output from command c:\users\chenl\anaconda3\envs\dand\python.exe -u -c "import setuptools, tokenize;file='c:\users\chenl\appdata\local\temp\pip-install-den8yg\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\chenl\appdata\local\temp\pip-record-gt_ov7\install-record.txt --single-version-externally-managed --compile: c:\users\chenl\anaconda3\envs\dand\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'long_description_content_type' warnings.warn(msg) running install running build running build_py creating build creating build\lib.win-amd64-2.7 creating build\lib.win-amd64-2.7\shap copying shap\common.py -> build\lib.win-amd64-2.7\shap copying shap\datasets.py -> build\lib.win-amd64-2.7\shap copying shap__init.py -> build\lib.win-amd64-2.7\shap creating build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\explainer.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\gradient.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\kernel.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\linear.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\mimic.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\pytree.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\sampling.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers\tree.py -> build\lib.win-amd64-2.7\shap\explainers copying shap\explainers__init.py -> build\lib.win-amd64-2.7\shap\explainers creating build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\coefficent.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\lime.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\random.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\treegain.py -> build\lib.win-amd64-2.7\shap\explainers\other copying shap\explainers\other\init.py -> build\lib.win-amd64-2.7\shap\explainers\other creating build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\deep_pytorch.py -> build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\deep_tf.py -> build\lib.win-amd64-2.7\shap\explainers\deep copying shap\explainers\deep\init__.py -> build\lib.win-amd64-2.7\shap\explainers\deep creating build\lib.win-amd64-2.7\shap\plots copying shap\plots\colors.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\dependence.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\embedding.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\force.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\force_matplotlib.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\image.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\monitoring.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\summary.py -> build\lib.win-amd64-2.7\shap\plots copying shap\plots\init.py -> build\lib.win-amd64-2.7\shap\plots creating build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\experiments.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\measures.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\methods.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\metrics.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\models.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\plots.py -> build\lib.win-amd64-2.7\shap\benchmark copying shap\benchmark\init__.py -> build\lib.win-amd64-2.7\shap\benchmark creating build\lib.win-amd64-2.7\shap\plots\resources copying shap\plots\resources\bundle.js -> build\lib.win-amd64-2.7\shap\plots\resources copying shap\plots\resources\logoSmallGray.png -> build\lib.win-amd64-2.7\shap\plots\resources copying shap\tree_shap.h -> build\lib.win-amd64-2.7\shap running build_ext ('numpy.get_include()', 'c:\users\chenl\anaconda3\envs\dand\lib\site-packages\numpy\core\include') building 'shap._cext' extension error: Microsoft Visual C++ 9.0 is required. Get it from http://aka.ms/vcpython27

----------------------------------------

Command "c:\users\chenl\anaconda3\envs\dand\python.exe -u -c "import setuptools, tokenize;file='c:\users\chenl\appdata\local\temp\pip-install-den8yg\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\chenl\appdata\local\temp\pip-record-gt_ov7\install-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:\users\chenl\appdata\local\temp\pip-install-den8yg\shap\

slundberg commented 5 years ago

Looks like you need to recompile, but don't have a compiler installed. Have you tried usingconda install -c conda-forge shap? Conda forge has precompiled binaries for more systems than pip does.

3rock618 commented 5 years ago

+1 Same issue

slundberg commented 5 years ago

It is because you don’t have a compiler installed. Use conda instead of pip and you should be fine (see the two install options in the main readme).

On Fri, Jul 12, 2019 at 2:48 PM 3rock618 notifications@github.com wrote:

+1 Same issue

— You are receiving this because you commented.

Reply to this email directly, view it on GitHub https://github.com/slundberg/shap/issues/539?email_source=notifications&email_token=AA4RHRM7DYTBKTDYSPPULATP7D3ZZA5CNFSM4HEMTOU2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZ26WZA#issuecomment-511044452, or mute the thread https://github.com/notifications/unsubscribe-auth/AA4RHRJUUTKBBCX45M4G4ATP7D3ZZANCNFSM4HEMTOUQ .

mmortazavi commented 5 years ago

Indeed conda install -c conda-forge shap solves the issue.

rezareshad92 commented 5 years ago

thanks. It resolves the issue.

jmathur25 commented 4 years ago

Sometimes pip install is more convenient because deployment services like AWS Elastic Beanstalk run pip install on a provided requirements.txt inside an environment. My server was not able to build the _ext module because it was missing g++. I was able to fix this on the CentOS machine by running sudo yum install gcc-c++ in a configuration file. Then I added easy_install shap and was done :)

ChenTaHung commented 4 years ago

It worked! I used conda install -c conda-forge shap and solved the problem. Thanks for the solution. I expect the package can be implemented in R, since I was a R user too.

Cahitisleyen commented 4 years ago

Using this conda install -c conda-forge shap really worked, thank you.

WaleAdelanwa commented 4 years ago

please I have similar issue, I am trying to install pycaret in anaconda prompt. I am getting the error

ERROR: Failed building wheel for shap

I have tried using

conda install -c conda-forge shap,

it insalled. I have installe microsoft studio c++ build tools.. I am still not able to solve this issue.. Kindly help

adriennekline commented 4 years ago

I used the conda install -c conda-forge shap and it is still failing. When i tried again with conda install -c conda-forge/label/cf201901 shap it threw an error indicating that because I was using python 3.8 it would not step back to an earlier version. Is there a version compatible with 3.8?

antonkulaga commented 3 years ago

Guys, you have outdated version of shap in conda-forge, so people have to use pip. Please, update conda-forge with latest version!

rank-p commented 3 years ago

Hi guys, as antonkulaga said, the conda version only has shaped 0.37.0. For installing with pip I get the same error.

Casyfill commented 3 years ago

Would be just really awesome to ship wheels for different os/python versions so we could use pip too. It is really not hard to do! We're using poetry/venv and it does not work with conda

detrin commented 1 year ago

Looking at https://github.com/shap/shap/blob/master/.github/workflows/build_wheels.yml Candidate for closing? @thatlittleboy

thatlittleboy commented 1 year ago

We ship wheels for all the major platforms now. I'll close this issue for now, those facing installation issues please raise a new issue.

Kkhurana007 commented 9 months ago

shap installation failed; python version- 3.12.1

  1. with pip I'm getting this error- image

  2. then looking at the official documentation, I was able to install it. It gets activated in the conda environment,

image

image

but I get the error when I work with it in the jupyter notebook- image

Any help?