Official Python SDK for Milvus, the open-source vector database. Has two coexisting APIs: the modern MilvusClient (recommended, introduced in 2.3) and the legacy ORM API (connections.connect + Collection class). Both currently work but LLM-generated and tutorial code overwhelmingly uses the old ORM patterns. Milvus Lite (embedded SQLite-based local mode) is available via the milvus-lite extra on Linux/macOS only. Server version must be kept in sync with client minor version.
pip install pymilvusVerified import paths — ran on the pinned version, not inferred.
MilvusClient is the recommended API for all new code. Milvus Lite works for prototyping on Linux/macOS but is NOT available on Windows.
Always align client and server versions. Check compatibility table: milvus.io/docs/release_notes.md. When upgrading server, upgrade client simultaneously.
On Windows, run a Milvus server (Docker) and connect via uri=. There is no embedded mode for Windows.
Use only one API style per codebase. Prefer MilvusClient for all new code. If migrating legacy ORM code, convert fully rather than mixing.
After connecting, explicitly call client.using_database('db_name') to ensure the correct database context is active.Call client.load_collection('name') before searching. For async load: poll client.get_load_state('name') until state is LoadState.Loaded before issuing queries.Only install [model] extra if you need local embedding generation. For production, generate embeddings separately and pass float vectors directly to insert/search.
Quote the package spec: pip install 'pymilvus[model]'
Ensure that build essential packages are installed in your environment. For Alpine Linux, run `apk add build-base g++`. For Debian/Ubuntu, use `apt-get install build-essential`. For CentOS/RHEL, use `yum install gcc-c++` or `dnf install gcc-c++`.