UKPLab/sentence-transformers

import sentence_transformers出错

Opened this issue · 1 comments

为什么我import以下模块会报错呢:
from sentence_transformers import SentenceTransformer
报这样的错:
Traceback (most recent call last):
File "/home/wmz/FlashRAG/try2.py", line 1, in
from sentence_transformers import SentenceTransformer
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sentence_transformers/init.py", line 10, in
from sentence_transformers.cross_encoder.CrossEncoder import CrossEncoder
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sentence_transformers/cross_encoder/init.py", line 3, in
from .CrossEncoder import CrossEncoder
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sentence_transformers/cross_encoder/CrossEncoder.py", line 18, in
from sentence_transformers.evaluation.SentenceEvaluator import SentenceEvaluator
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sentence_transformers/evaluation/init.py", line 3, in
from .BinaryClassificationEvaluator import BinaryClassificationEvaluator
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sentence_transformers/evaluation/BinaryClassificationEvaluator.py", line 10, in
from sklearn.metrics import average_precision_score
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/init.py", line 73, in
from .base import clone # noqa: E402
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/base.py", line 19, in
from .utils._estimator_html_repr import _HTMLDocumentationLinkMixin, estimator_html_repr
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/init.py", line 15, in
from ._chunking import gen_batches, gen_even_slices
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/_chunking.py", line 11, in
from ._param_validation import Interval, validate_params
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/_param_validation.py", line 17, in
from .validation import _is_arraylike_not_scalar
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/validation.py", line 21, in
from ..utils._array_api import _asarray_with_order, _is_numpy_namespace, get_namespace
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/_array_api.py", line 17, in
from .fixes import parse_version
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/sklearn/utils/fixes.py", line 17, in
import scipy.stats
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/stats/init.py", line 606, in
from ._stats_py import *
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/stats/_stats_py.py", line 49, in
from . import distributions
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/stats/distributions.py", line 11, in
from . import _discrete_distns
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/stats/_discrete_distns.py", line 10, in
from scipy.interpolate import interp1d
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/interpolate/init.py", line 167, in
from ._interpolate import *
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/interpolate/_interpolate.py", line 14, in
from . import _fitpack_py
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/interpolate/_fitpack_py.py", line 8, in
from ._fitpack_impl import bisplrep, bisplev, dblint # noqa: F401
File "/data/anaconda3/envs/flashrag/lib/python3.9/site-packages/scipy/interpolate/_fitpack_impl.py", line 103, in
'iwrk': array([], dfitpack_int), 'u': array([], float),
TypeError

sentence-transformers的版本是3.2.1

Hello!

Other people have this issue too I think: scipy/scipy#21014
Some people offered solutions:

  • Increase Python version
  • pip install scipy==1.14.1 or pip install 'scipy<1.13.0'
  • reinstall scipy

Consider trying out a few options there.

  • Tom Aarsen