1
0

More than 1 year has passed since last update.

poetryでshapがadd出来ない時の対処法

Posted at

挨拶の前に結論

自分の場合はnumba(0.56.4)とnumpyのバージョンがコンフリクト起こしてた

poetry add numpy=1.23.3

これでinstallすれば解決

poetry add shap

本編

お疲れ様です。
最近XAIに興味を持ってSHAPを使おうと思い、

poetry add shap

をしたところ
たくさんエラーが出ている最後の方に

Note: This error originates from the build 
backend, and is likely not a problem with poetry 
but with llvmlite (0.34.0) not supporting PEP 517 
builds. You can verify this by running 'pip wheel 
--use-pep517 "llvmlite (==0.34.0) ; 
python_version >= "3.6""'.

と書いてあるようなエラーが出てきます。
まあ、今時ChatGPTにエラーハンドリングさせれば解決することが多いですが、解決しなかったので書いてます。
(ちゃんとしたプロンプトを投げれば解決してくれると思いますが)

エラー原因はおそらくllvmlitenumbaがInstall出来ないことが原因だと思います。

poetry add llvmlite

でllvmliteはすぐに突破できてしまったので今回はnumbaについて書いていきます。

「なんでinstall出来ないねん!」と思い

poetry add numba

を実行すると
赤い、怖い文字で

Because no versions of numba match >0.56.4,<0.57.0
 and numba (0.56.4) depends on numpy (>=1.18,
<1.24), numba (>=0.56.4,<0.57.0) requires numpy 
(>=1.18,<1.24).
So, because streamlit-app depends on both numpy 
(^1.24.2) and numba (^0.56.4), version solving 
failed.

と出てきます。
ホーンと思いながら見てみると、

numpy = "^1.24.2"

でして、これには対応してないっぽいんですよね。

1.24未満なら対応しているっぽいので、numpy=1.23.3をaddします!

pandas^1.5.3の場合、numpy (=>1.23.2)の必要があるので注意しましょう

poetry add numpy=1.23.3

これでinstallすれば解決

poetry add shap
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0