ModuleNotFoundError: No module named 'milvus'

ModuleNotFoundError: No module named 'milvus'

目标:在 AWS SageMaker Jupyter Labs 上 运行 此自动标记 Notebook

内核已尝试:conda_pytorch_p36conda_python3conda_amazonei_mxnet_p27


! pip install farm-haystack -q
# Install the latest master of Haystack
!pip install grpcio-tools==1.34.1 -q
!pip install git+https://github.com/deepset-ai/haystack.git -q
!wget --no-check-certificate https://dl.xpdfreader.com/xpdf-tools-linux-4.03.tar.gz
!tar -xvf xpdf-tools-linux-4.03.tar.gz && sudo cp xpdf-tools-linux-4.03/bin64/pdftotext /usr/local/bin
!pip install git+https://github.com/deepset-ai/haystack.git -q
# Here are the imports we need
from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore
from haystack.nodes import PreProcessor, TransformersDocumentClassifier, FARMReader, ElasticsearchRetriever
from haystack.schema import Document
from haystack.utils import convert_files_to_dicts, fetch_archive_from_http, print_answers

回溯:

02/02/2022 10:36:29 - INFO - faiss.loader -   Loading faiss with AVX2 support.
02/02/2022 10:36:29 - INFO - faiss.loader -   Could not load library with AVX2 support due to:
ModuleNotFoundError("No module named 'faiss.swigfaiss_avx2'",)
02/02/2022 10:36:29 - INFO - faiss.loader -   Loading faiss.
02/02/2022 10:36:29 - INFO - faiss.loader -   Successfully loaded faiss.
02/02/2022 10:36:33 - INFO - farm.modeling.prediction_head -   Better speed can be achieved with apex installed from https://www.github.com/nvidia/apex .
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-4-6ff421127e9c> in <module>
      1 # Here are the imports we need
----> 2 from haystack.document_stores.elasticsearch import ElasticsearchDocumentStore
      3 from haystack.nodes import PreProcessor, TransformersDocumentClassifier, FARMReader, ElasticsearchRetriever
      4 from haystack.schema import Document
      5 from haystack.utils import convert_files_to_dicts, fetch_archive_from_http, print_answers

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/__init__.py in <module>
      3 import pandas as pd
      4 from haystack.schema import Document, Label, MultiLabel, BaseComponent
----> 5 from haystack.finder import Finder
      6 from haystack.pipeline import Pipeline
      7 

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/finder.py in <module>
      6 from collections import defaultdict
      7 
----> 8 from haystack.reader.base import BaseReader
      9 from haystack.retriever.base import BaseRetriever
     10 from haystack import MultiLabel

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/reader/__init__.py in <module>
----> 1 from haystack.reader.farm import FARMReader
      2 from haystack.reader.transformers import TransformersReader

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/reader/farm.py in <module>
     22 
     23 from haystack import Document
---> 24 from haystack.document_store.base import BaseDocumentStore
     25 from haystack.reader.base import BaseReader
     26 

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/document_store/__init__.py in <module>
      2 from haystack.document_store.faiss import FAISSDocumentStore
      3 from haystack.document_store.memory import InMemoryDocumentStore
----> 4 from haystack.document_store.milvus import MilvusDocumentStore
      5 from haystack.document_store.sql import SQLDocumentStore

~/anaconda3/envs/pytorch_p36/lib/python3.6/site-packages/haystack/document_store/milvus.py in <module>
      5 import numpy as np
      6 
----> 7 from milvus import IndexType, MetricType, Milvus, Status
      8 from scipy.special import expit
      9 from tqdm import tqdm

ModuleNotFoundError: No module named 'milvus'

pip install milvus
import milvus

回溯:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-91c33e248077> in <module>
----> 1 import milvus

ModuleNotFoundError: No module named 'milvus'

我建议您在一周前将您的 milvus 版本降级到 2.0 发布之前的版本。这是关于该主题的讨论:https://github.com/deepset-ai/haystack/issues/2081

我遇到了同样的问题,我通过简单地卸载 pymilvus 并重新安装旧版本来解决它。

pip list 展示了 pymilvus v2.0.0

pip uninstall pymilvus 删除了当前版本

pip install pymilvus==1.1.2 安装了旧版本,瞧瞧;

它运行平稳