How to beginner · 3 min read

How to install ChromaDB

Quick answer
Install ChromaDB by running pip install chromadb in your Python environment. This installs the official Python client for ChromaDB, enabling vector database functionality for AI applications.

PREREQUISITES

  • Python 3.8+
  • pip package manager

Setup

To install ChromaDB, ensure you have Python 3.8 or higher and pip installed. Then run the installation command below in your terminal or command prompt.

bash
pip install chromadb

Step by step

After installation, you can import and initialize ChromaDB in your Python code to create and query a vector database.

python
import chromadb

# Create a client instance
client = chromadb.Client()

# Create a collection
collection = client.create_collection(name="example_collection")

# Add vectors and metadata
collection.add(
    documents=["Hello world", "ChromaDB example"],
    embeddings=[[0.1, 0.2, 0.3], [0.4, 0.5, 0.6]],
    metadatas=[{"source": "doc1"}, {"source": "doc2"}],
    ids=["id1", "id2"]
)

# Query the collection
results = collection.query(
    query_embeddings=[[0.1, 0.2, 0.3]],
    n_results=1
)

print(results)
output
{'ids': [['id1']], 'distances': [[0.0]], 'metadatas': [[{'source': 'doc1'}]], 'documents': [['Hello world']]}

Common variations

You can customize ChromaDB usage by configuring persistent storage, using different embedding models, or running it asynchronously with frameworks like asyncio. The basic installation remains the same.

Troubleshooting

  • If you see ModuleNotFoundError, verify chromadb installed in the correct Python environment.
  • For permission errors, try running pip install --user chromadb or use a virtual environment.
  • Check Python version with python --version to ensure compatibility.

Key Takeaways

  • Use pip install chromadb to install the official Python client.
  • Initialize chromadb.Client() to start using the vector database.
  • Add vectors and metadata to collections for efficient similarity search.
  • Troubleshoot installation issues by verifying Python environment and permissions.
Verified 2026-04
Verify ↗