0

我正在 pycharm 中开发一个项目,该项目位于 Mac OS 的虚拟环境中。我一直在尝试安装 SHAP 包,不幸的是它没有成功。以下是完整的错误消息。似乎存在一个似乎不存在的 SDK 的问题,但是当我在虚拟环境之外安装包时,我没有遇到任何问题。

Collecting shap
  Using cached shap-0.35.0.tar.gz (273 kB)
Requirement already satisfied: numpy in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from shap) (1.19.0)
Requirement already satisfied: scipy in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from shap) (1.5.1)
Requirement already satisfied: scikit-learn in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from shap) (0.23.1)
Requirement already satisfied: pandas in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from shap) (1.0.5)
Requirement already satisfied: tqdm>4.25.0 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from shap) (4.48.0)
Requirement already satisfied: joblib>=0.11 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from scikit-learn->shap) (0.16.0)
Requirement already satisfied: threadpoolctl>=2.0.0 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from scikit-learn->shap) (2.1.0)
Requirement already satisfied: python-dateutil>=2.6.1 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from pandas->shap) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from pandas->shap) (2020.1)
Requirement already satisfied: six>=1.5 in /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages (from python-dateutil>=2.6.1->pandas->shap) (1.15.0)
Using legacy setup.py install for shap, since package 'wheel' is not installed.
Installing collected packages: shap
    Running setup.py install for shap: started
    Running setup.py install for shap: finished with status 'error'

    ERROR: Command errored out with exit status 1:
     command: /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pycharm-packaging/shap/setup.py'"'"'; __file__='"'"'/private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pycharm-packaging/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 /private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pip-record-92beasur/install-record.txt --single-version-externally-managed --compile --install-headers /Users/geilerloui/Documents/GitHub/churn_dashboard/venv/include/site/python3.7/shap
         cwd: /private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pycharm-packaging/shap/
    Complete output (83 lines):
    /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.macosx-10.14-x86_64-3.7
    creating build/lib.macosx-10.14-x86_64-3.7/shap
    copying shap/datasets.py -> build/lib.macosx-10.14-x86_64-3.7/shap
    copying shap/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap
    copying shap/common.py -> build/lib.macosx-10.14-x86_64-3.7/shap
    creating build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/tree.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/partition.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/kernel.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/explainer.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/bruteforce.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/gradient.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/linear.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/mimic.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/permutation.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/sampling.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/additive.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/tf_utils.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    copying shap/explainers/pytree.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers
    creating build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/coefficent.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/maple.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/lime.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/random.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    copying shap/explainers/other/treegain.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/other
    creating build/lib.macosx-10.14-x86_64-3.7/shap/explainers/deep
    copying shap/explainers/deep/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/deep
    copying shap/explainers/deep/deep_pytorch.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/deep
    copying shap/explainers/deep/deep_tf.py -> build/lib.macosx-10.14-x86_64-3.7/shap/explainers/deep
    creating build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/force_matplotlib.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/force.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/embedding.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/monitoring.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/colorconv.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/decision.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/waterfall.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/summary.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/text.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/dependence.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/bar.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/image.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/partial_dependence.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    copying shap/plots/colors.py -> build/lib.macosx-10.14-x86_64-3.7/shap/plots
    creating build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/metrics.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/models.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/methods.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/__init__.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/measures.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/plots.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    copying shap/benchmark/experiments.py -> build/lib.macosx-10.14-x86_64-3.7/shap/benchmark
    creating build/lib.macosx-10.14-x86_64-3.7/shap/plots/resources
    copying shap/plots/resources/bundle.js -> build/lib.macosx-10.14-x86_64-3.7/shap/plots/resources
    copying shap/plots/resources/logoSmallGray.png -> build/lib.macosx-10.14-x86_64-3.7/shap/plots/resources
    copying shap/tree_shap.h -> build/lib.macosx-10.14-x86_64-3.7/shap
    warning: build_py: byte-compiling is disabled, skipping.
    
    running build_ext
    numpy.get_include() /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages/numpy/core/include
    building 'shap._cext' extension
    creating build/temp.macosx-10.14-x86_64-3.7
    creating build/temp.macosx-10.14-x86_64-3.7/shap
    Compiling with an SDK that doesn't seem to exist: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
    Please check your Xcode installation
    x86_64-apple-darwin13.4.0-clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe -D_FORTIFY_SOURCE=2 -mmacosx-version-min=10.9 -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/include -I/usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -I/Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/lib/python3.7/site-packages/numpy/core/include -c shap/_cext.cc -o build/temp.macosx-10.14-x86_64-3.7/shap/_cext.o
    clang-4.0: warning: no such sysroot directory: '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk' [-Wmissing-sysroot]
    In file included from shap/_cext.cc:3:
    In file included from /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m/Python.h:25:
    /anaconda3/bin/../include/c++/v1/stdio.h:108:15: fatal error: 'stdio.h' file not found
    #include_next <stdio.h>
                  ^~~~~~~~~
    1 error generated.
    error: command 'x86_64-apple-darwin13.4.0-clang' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pycharm-packaging/shap/setup.py'"'"'; __file__='"'"'/private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pycharm-packaging/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 /private/var/folders/gk/rzy7hgz11nxcx5y0bjgsndx40000gn/T/pip-record-92beasur/install-record.txt --single-version-externally-managed --compile --install-headers /Users/xxxxxx/Documents/GitHub/churn_dashboard/venv/include/site/python3.7/shap Check the logs for full command output.
4

1 回答 1

1

我对最新的shap图书馆有困难。

因此我目前正在使用shap==0.31.0版本

我想将shap包与tensorflowand一起使用keras

这是我的工作组合:

Keras==2.3.1
Keras-Applications==1.0.8
Keras-Preprocessing==1.1.0
numpy==1.18.1
pandas==1.0.3
scikit-image==0.16.2
scikit-learn==0.22.1
scipy==1.4.1
shap==0.31.0
six==1.14.0
tensorboard==1.15.0
tensorflow==1.15.0
tensorflow-estimator==1.15.1
tensorflow-tensorboard==0.1.8
Theano==0.8.2
tqdm==4.46.0
Werkzeug==0.16.1
于 2020-07-24T23:05:14.600 回答