Last modified: Jun 06, 2026

Install LlamaIndex in Python

LlamaIndex is a powerful data framework for building LLM applications. It helps you connect custom data sources to large language models. Installing it correctly is the first step to building smart search or QA systems.

This guide walks you through the process step by step. You will learn the prerequisites, the installation command, and how to verify the setup. We also cover common issues and solutions.

What is LlamaIndex?

LlamaIndex acts as a bridge between your data and LLMs. It indexes documents and makes them queryable. You can use it for retrieval-augmented generation (RAG) applications.

Before installing, ensure you have Python 3.8 or higher. LlamaIndex works on Windows, macOS, and Linux. A stable internet connection is also needed.

Prerequisites

Make sure you have Python 3.8+ installed. You can check your version with:


python --version

If you don't have Python, download it from the official website. We recommend using a virtual environment to avoid package conflicts.

Step 1: Create a Virtual Environment

Isolating your project environment is a best practice. Use venv to create one:


python -m venv llama_env

Activate it. On Windows run:


llama_env\Scripts\activate

On macOS/Linux run:


source llama_env/bin/activate

You should see (llama_env) in your terminal prompt.

Step 2: Install LlamaIndex with pip

The simplest way to install is via pip. Run this command:


pip install llama-index

This installs the core library and common dependencies like OpenAI and Chroma. The process may take a few minutes.

You can also install a minimal version for faster setup:


pip install llama-index-core

Then add extra integrations as needed, such as llama-index-llms-openai.

Step 3: Verify the Installation

Open a Python shell and try importing LlamaIndex:


# test_install.py
import llama_index

print("LlamaIndex version:", llama_index.__version__)

Run the script:


python test_install.py

Expected output:


LlamaIndex version: 0.10.0

If you see the version number, the installation succeeded.

Step 4: Install Optional Dependencies

LlamaIndex supports many vector stores and LLMs. For example, to use ChromaDB, install:


pip install llama-index-vector-stores-chroma

For local LLMs with Ollama:


pip install llama-index-llms-ollama

Check the official documentation for all available integrations.

Common Installation Issues

Problem: pip command not found. This means Python is not in your PATH. Reinstall Python and check the "Add to PATH" option.

Problem: Version conflicts. Use a fresh virtual environment to avoid clashes with existing packages.

Problem: Slow download. Use a mirror or upgrade pip first:


pip install --upgrade pip

Quick Example: Index a Document

After installation, test a simple indexing workflow. Create a file example.py:


# example.py
from llama_index.core import SimpleDirectoryReader, VectorStoreIndex

# Load documents from the current directory
documents = SimpleDirectoryReader(".").load_data()

# Build an index
index = VectorStoreIndex.from_documents(documents)

# Query the index
query_engine = index.as_query_engine()
response = query_engine.query("What is LlamaIndex?")
print(response)

Place a text file in the same folder and run:


python example.py

If you have an OpenAI API key set, you'll get a relevant answer.

Best Practices

Always use a virtual environment. Keep your packages updated with pip install --upgrade llama-index. Store API keys in environment variables, not in code.

For production, consider using poetry or conda for dependency management.

Conclusion

Installing LlamaIndex in Python is straightforward with pip. Create a virtual environment, run the install command, and verify it works. You can now build powerful RAG applications.

Start with the minimal core package and add integrations as needed. This keeps your environment clean and fast. Happy coding!