Pip虚拟环境中的Pip安装SHAP失败



我在Linux服务器上使用Python 3.6.3上的pip虚拟环境。

我尝试pip安装SHAP,但遇到以下错误:

Building wheel for shap (setup.py) ... error
ERROR: Complete output from command XXXX/bin/python -u -c 'import setuptools, tokenize;__file__='"'"'/tmp/pip-install-aq97v0m2/shap/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'rn'"'"', '"'"'n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-v9vyt50m --python-tag cp36:
ERROR: running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/shap
copying shap/common.py -> build/lib.linux-x86_64-3.6/shap
copying shap/__init__.py -> build/lib.linux-x86_64-3.6/shap
copying shap/datasets.py -> build/lib.linux-x86_64-3.6/shap
creating build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/pytree.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/deep.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/sampling.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/mimic.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/__init__.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/linear.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/gradient.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/explainer.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/kernel.py -> build/lib.linux-x86_64-3.6/shap/explainers
copying shap/explainers/tree.py -> build/lib.linux-x86_64-3.6/shap/explainers
creating build/lib.linux-x86_64-3.6/shap/explainers/other
copying shap/explainers/other/random.py -> build/lib.linux-x86_64-3.6/shap/explainers/other
copying shap/explainers/other/__init__.py -> build/lib.linux-x86_64-3.6/shap/explainers/other
copying shap/explainers/other/coefficent.py -> build/lib.linux-x86_64-3.6/shap/explainers/other
creating build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/colors.py -> build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/image.py -> build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/dependence.py -> build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/summary.py -> build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/__init__.py -> build/lib.linux-x86_64-3.6/shap/plots
copying shap/plots/force.py -> build/lib.linux-x86_64-3.6/shap/plots
creating build/lib.linux-x86_64-3.6/shap/benchmark
copying shap/benchmark/plots.py -> build/lib.linux-x86_64-3.6/shap/benchmark
copying shap/benchmark/__init__.py -> build/lib.linux-x86_64-3.6/shap/benchmark
copying shap/benchmark/methods.py -> build/lib.linux-x86_64-3.6/shap/benchmark
copying shap/benchmark/scorers.py -> build/lib.linux-x86_64-3.6/shap/benchmark
copying shap/benchmark/metrics.py -> build/lib.linux-x86_64-3.6/shap/benchmark
creating build/lib.linux-x86_64-3.6/shap/plots/resources
copying shap/plots/resources/logoSmallGray.png -> build/lib.linux-x86_64-3.6/shap/plots/resources
copying shap/plots/resources/bundle.js -> build/lib.linux-x86_64-3.6/shap/plots/resources
running build_ext
numpy.get_include() /usr/local/share/anaconda/anaconda3-5.0.1/lib/python3.6/site-packages/numpy/core/include
building 'shap._cext' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/shap
gcc -pthread -B /usr/local/share/anaconda/anaconda3-5.0.1/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/XXX/include -I/usr/local/share/anaconda/anaconda3-5.0.1/include/python3.6m -I/usr/local/share/anaconda/anaconda3-5.0.1/lib/python3.6/site-packages/numpy/core/include -c shap/_cext.cc -o build/temp.linux-x86_64-3.6/shap/_cext.o
gcc: error trying to exec 'cc1plus': execvp: No such file or directory
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: 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

我浏览了一些类似的问题,并尝试通过指定包版本来安装SHAP,但没有任何成功。

你能给我建议吗?提前感谢!

导致安装崩溃的错误是:

error trying to exec 'cc1plus': execvp: No such file or directory

可以通过安装g++进行修复:

sudo apt-get install g++

如果消息显示为:找不到包,请尝试以下命令:

sudo apt-get update && sudo apt-get upgrade
sudo apt-get install g++

最新更新