即使更新所有库,导入SHAP也会发生错误

问题描述 投票:0回答:1

当我导入

shap
时,出现如下错误。

我尝试重新安装

shap
并更新
conda
numpy
numba
llvmlite

有趣的是,jupyter笔记本中的

llvmlite
版本是0.38.0,但出现的错误与下面相同。

意外异常格式化异常。回到标准异常

Traceback (most recent call last):
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 3369, in run_code
    ----------
  File "C:\Users\user\AppData\Local\Temp\ipykernel_22980\3975714860.py", line 1, in <cell line: 1>
    import shap
  File "C:\Users\user\anaconda3\lib\site-packages\shap\__init__.py", line 12, in <module>
    from ._explanation import Explanation, Cohorts
  File "C:\Users\user\anaconda3\lib\site-packages\shap\_explanation.py", line 12, in <module>
    from .utils._general import OpChain
  File "C:\Users\user\anaconda3\lib\site-packages\shap\utils\__init__.py", line 1, in <module>
    from ._clustering import hclust_ordering, partition_tree, partition_tree_shuffle, delta_minimization_order, hclust
  File "C:\Users\user\anaconda3\lib\site-packages\shap\utils\_clustering.py", line 4, in <module>
    from numba import jit
  File "C:\Users\user\anaconda3\lib\site-packages\numba\__init__.py", line 199, in <module>
    _ensure_llvm()
  File "C:\Users\user\anaconda3\lib\site-packages\numba\__init__.py", line 111, in _ensure_llvm
    raise ImportError(msg)
ImportError: Numba requires at least version 0.38.0 of llvmlite.
Installed version is 0.37.0.
Please update llvmlite.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\interactiveshell.py", line 1982, in showtraceback
    'the full traceback.\n']
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1118, in structured_traceback
    return FormattedTB.structured_traceback(
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\ultratb.py", line 1012, in structured_traceback
    return VerboseTB.structured_traceback(
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\ultratb.py", line 865, in structured_traceback
    formatted_exception = self.format_exception_as_a_whole(etype, evalue, etb, number_of_lines_of_context,
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\ultratb.py", line 818, in format_exception_as_a_whole
    frames.append(self.format_record(r))
  File "C:\Users\user\anaconda3\lib\site-packages\IPython\core\ultratb.py", line 736, in format_record
    result += ''.join(_format_traceback_lines(frame_info.lines, Colors, self.has_colors, lvals))
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\core.py", line 698, in lines
    pieces = self.included_pieces
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\core.py", line 649, in included_pieces
    pos = scope_pieces.index(self.executing_piece)
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\utils.py", line 145, in cached_property_wrapper
    value = obj.__dict__[self.func.__name__] = self.func(obj)
  File "C:\Users\user\anaconda3\lib\site-packages\stack_data\core.py", line 628, in executing_piece
    return only(
  File "C:\Users\user\anaconda3\lib\site-packages\executing\executing.py", line 164, in only
    raise NotOneValueFound('Expected one value, found 0')
executing.executing.NotOneValueFound: Expected one value, found 0

在我尝试使用“conda update llvmlite”进行更新后。

我收到如下错误。我应该做什么?

(base) C:\Users\user>conda update llvmlite
Collecting package metadata (current_repodata.json): failed

CondaSSLError: OpenSSL appears to be unavailable on this machine. OpenSSL is required to
download and install packages.

Exception: HTTPSConnectionPool(host='repo.anaconda.com', port=443): Max retries exceeded with url: /pkgs/main/win-64/current_repodata.json (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available."))
python numba shap
1个回答
0
投票

导入时

numba
llvm
版本有冲突。

仔细阅读以下几行:

ImportError: Numba requires at least version 0.38.0 of llvmlite.
Installed version is 0.37.0.
Please update llvmlite.

尝试:

conda list llvmlite

或者,如果需要的话

conda update llvmlite

正如您声称的路径中已经有正确的

llvmlite
,我认为最短的路径是做

conda deactivate
pip install -U llvmlite

否则,请在您的

$PATH
/
env
定义中查找问题

© www.soinside.com 2019 - 2024. All rights reserved.