FoundationAgents/MetaGPT · error · Exception
Please install pymilvus first.
Error message
Please install pymilvus first.
What it means
MilvusStore.__init__ tries to import pymilvus.MilvusClient inside a try/except and raises 'Please install pymilvus first.' on ImportError. The dependency is optional: it is only declared in MetaGPT's rag/milvus extras, not the base install, so MilvusStore is unusable without it.
Source
Thrown at metagpt/document_store/milvus_store.py:24
@dataclass
class MilvusConnection:
"""
Args:
uri: milvus url
token: milvus token
"""
uri: str = None
token: str = None
class MilvusStore(BaseStore):
def __init__(self, connect: MilvusConnection):
try:
from pymilvus import MilvusClient
except ImportError:
raise Exception("Please install pymilvus first.")
if not connect.uri:
raise Exception("please check MilvusConnection, uri must be set.")
self.client = MilvusClient(uri=connect.uri, token=connect.token)
def create_collection(self, collection_name: str, dim: int, enable_dynamic_schema: bool = True):
from pymilvus import DataType
if self.client.has_collection(collection_name=collection_name):
self.client.drop_collection(collection_name=collection_name)
schema = self.client.create_schema(
auto_id=False,
enable_dynamic_field=False,
)
schema.add_field(field_name="id", datatype=DataType.VARCHAR, is_primary=True, max_length=36)
schema.add_field(field_name="vector", datatype=DataType.FLOAT_VECTOR, dim=dim)
index_params = self.client.prepare_index_params()View on GitHub (pinned to 11cdf466d0)
Solutions
- Install the dependency: pip install pymilvus (or pip install 'metagpt[milvus]' if you installed MetaGPT from PyPI with extras).
- Pin a compatible version, e.g. pip install 'pymilvus>=2.4' — MilvusClient and create_schema require the 2.x client API.
- For deployments, add pymilvus to requirements.txt / Dockerfile so the image is self-contained.
Example fix
# before store = MilvusStore(MilvusConnection(uri="http://localhost:19530")) # Exception: Please install pymilvus first. # after # shell: pip install pymilvus store = MilvusStore(MilvusConnection(uri="http://localhost:19530"))
Defensive patterns
Strategy: validation
Validate before calling
def milvus_available() -> bool:
try:
import pymilvus # noqa: F401
return True
except ImportError:
return False
if not milvus_available():
raise SystemExit("Install with: pip install 'metagpt[milvus]' (or pip install pymilvus)") Try / catch
try:
store = MilvusStore(conn)
except Exception as e:
if "install pymilvus" in str(e):
raise SystemExit("missing dependency; run: pip install pymilvus") from e
raise Prevention
- Install MetaGPT with the milvus extra from day one when the Milvus store is part of your design.
- Add pymilvus to requirements/Dockerfile so images are self-contained.
- Add a startup dependency check (import pymilvus) that reports the install command instead of failing at first store construction.
When it happens
Trigger: Constructing MilvusStore(MilvusConnection(uri=..., token=...)) in an environment where the pymilvus package is not installed (no metagpt[milvus] extra).
Common situations: pip install metagpt without extras then using the Milvus document store; CI images trimmed of optional deps; a new team member following the base README; upgrading Python versions and losing the previously installed pymilvus.
Related errors
- To use the experience pool, you need to install the rag modu
- please check MilvusConnection, uri must be set.
- Missing fields: {missing_fields}
- use `review` after `fill`
- Data type not supported for metadata extraction.
AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14).
Data as JSON: /api/errors/af8bd4fada9ca141.
Report an issue: GitHub.