Skip to content

Importlib.util needs to be directly imported #204

@amanchoudhri

Description

@amanchoudhri

On Python 3.12, attempting to import DenseRetrievalExactSearch,

from beir.retrieval.search.dense.exact_search import DenseRetrievalExactSearch as DRES

throws an AttributeError:

Traceback (most recent call last):
  File "/workspace/exa-bin-quant/bin_quant/encode.py", line 3, in <module>
    from beir.retrieval.search.dense.exact_search import DenseRetrievalExactSearch as DRES
  File "/workspace/exa-bin-quant/.venv/lib/python3.12/site-packages/beir/retrieval/search/dense/__init__.py", line 3, in <module>
    from .exact_search import DenseRetrievalExactSearch
  File "/workspace/exa-bin-quant/.venv/lib/python3.12/site-packages/beir/retrieval/search/dense/exact_search.py", line 8, in <module>
    if importlib.util.find_spec("faiss") is not None:
       ^^^^^^^^^^^^^^
AttributeError: module 'importlib' has no attribute 'util'

It seems that importlib doesn't expose util by default. See this Python stdlib thread, for example.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions