【问题标题】:Numba needs NumPy 1.20 or less for shapley importNumba 需要 NumPy 1.20 或更低版本才能导入 shapley
【发布时间】:2021-11-28 22:37:52
【问题描述】:

我正在尝试导入 shap。我收到以下错误。我安装了低版本的 NumPy 仍然没有解决问题。谢谢!

 import shap


ImportError                               Traceback (most recent call last)
/tmp/ipykernel_22681/948769371.py in <module>
----> 1 import shap

~/jupyter/environment/lib/python3.8/site-packages/shap/__init__.py in <module>
     10     warnings.warn("As of version 0.29.0 shap only supports Python 3 (not 2)!")
     11 
---> 12 from ._explanation import Explanation, Cohorts
     13 
     14 # explainers

~/jupyter/environment/lib/python3.8/site-packages/shap/_explanation.py in <module>
     10 from slicer import Slicer, Alias, Obj
     11 # from ._order import Order
---> 12 from .utils._general import OpChain
     13 
     14 # slicer confuses pylint...

~/jupyter/environment/lib/python3.8/site-packages/shap/utils/__init__.py in <module>
----> 1 from ._clustering import hclust_ordering, partition_tree, partition_tree_shuffle, delta_minimization_order, hclust
      2 from ._general import approximate_interactions, potential_interactions, sample, safe_isinstance, assert_import, record_import_error
      3 from ._general import shapley_coefficients, convert_name, format_value, ordinal_str, OpChain
      4 from ._show_progress import show_progress
      5 from ._masked_model import MaskedModel, make_masks

~/jupyter/environment/lib/python3.8/site-packages/shap/utils/_clustering.py in <module>
      2 import scipy as sp
      3 from scipy.spatial.distance import pdist
----> 4 from numba import jit
      5 import sklearn
      6 import warnings

~/jupyter/environment/lib/python3.8/site-packages/numba/__init__.py in <module>
    196 
    197 _ensure_llvm()
--> 198 _ensure_critical_deps()
    199 
    200 # we know llvmlite is working as the above tests passed, import it now as SVML

~/jupyter/environment/lib/python3.8/site-packages/numba/__init__.py in _ensure_critical_deps()
    136         raise ImportError("Numba needs NumPy 1.17 or greater")
    137     elif numpy_version > (1, 20):
--> 138         raise ImportError("Numba needs NumPy 1.20 or less")
    139 
    140     try:

ImportError: Numba needs NumPy 1.20 or less

【问题讨论】:

    标签: python import shapley


    【解决方案1】:

    我使用Numpy==1.21.4Numba==0.53.0,它有效:

    pip install numba==0.53
    

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。解决方案是使用 numpa 0.48.0 安装 numpy 1.18.1,它应该可以工作

      【讨论】:

        猜你喜欢
        • 2019-07-14
        • 2016-10-22
        • 2021-09-29
        • 2016-10-22
        • 1970-01-01
        • 1970-01-01
        • 2021-09-10
        • 1970-01-01
        • 2021-06-26
        相关资源
        最近更新 更多