Environment:Run llama Llama index Python LlamaIndex Core
| Knowledge Sources | |
|---|---|
| Domains | Infrastructure, RAG, NLP |
| Last Updated | 2026-02-11 19:00 GMT |
Overview
Python 3.9+ environment with LlamaIndex core dependencies including tiktoken, pydantic 2.8+, SQLAlchemy, and NLTK for RAG pipeline execution.
Description
This environment provides the base Python runtime and dependency stack required to run all LlamaIndex core workflows: RAG query pipelines, data ingestion pipelines, ReAct agents, and evaluation pipelines. It is built on Python 3.9+ (3.10+ for the finetuning package) and includes critical dependencies like tiktoken for tokenization, pydantic for data validation, SQLAlchemy for storage backends, NLTK for text processing, and nest-asyncio for event loop compatibility in notebook environments.
Usage
Use this environment for any LlamaIndex workflow. It is the mandatory base prerequisite for running all Implementation pages in this wiki. Without these dependencies, no LlamaIndex code will execute.
System Requirements
| Category | Requirement | Notes |
|---|---|---|
| OS | Linux, macOS, or Windows (WSL recommended) | Cross-platform support |
| Python | >=3.9, <4.0 | Finetuning package requires >=3.10 |
| Disk | ~500MB | For package installation and NLTK/tiktoken caches |
| Network | Internet access for initial setup | Downloads NLTK data and tiktoken encodings |
Dependencies
System Packages
- No special system packages required for core functionality
- git (for LlamaHub module downloads)
Python Packages
- `llama-index-core` >= 0.14.14
- `pydantic` >= 2.8.0
- `tiktoken` >= 0.7.0
- `SQLAlchemy[asyncio]` >= 1.4.49
- `nest-asyncio` >= 1.5.8, < 2
- `nltk` > 3.8.1
- `numpy`
- `tenacity` >= 8.2.0, != 8.4.0, < 10.0.0
- `aiohttp` >= 3.8.6, < 4
- `fsspec` >= 2023.5.0
- `networkx` >= 3.0
- `tqdm` >= 4.66.1, < 5
- `pillow` >= 9.0.0
- `PyYAML` >= 6.0.1
- `typing-extensions` >= 4.5.0
- `requests` >= 2.31.0
- `platformdirs`
- `banks` >= 2.2.0, < 3
- `llama-index-workflows` >= 2, < 3, != 2.9.0
- `eval-type-backport` >= 0.2.0, < 0.3 (Python < 3.10 only)
Credentials
The following environment variables are optional for core functionality:
- `LLAMA_INDEX_CACHE_DIR`: Override default cache directory location (defaults to platform cache via `platformdirs`)
- `NLTK_DATA`: Override NLTK data directory location
- `TIKTOKEN_CACHE_DIR`: Override tiktoken encoding cache location (auto-set to `_static/tiktoken_cache` if unset)
- `IS_TESTING`: Set to any value to bypass default LLM/embed model resolution in tests
Quick Install
# Install the base LlamaIndex package (pulls in all core dependencies)
pip install llama-index-core>=0.14.14
# Or install the full meta-package with OpenAI defaults
pip install llama-index>=0.14.14
Code Evidence
Tiktoken dependency check from `utils.py:157-163`:
tiktoken_import_err = (
"`tiktoken` package not found, please run `pip install tiktoken`"
)
try:
import tiktoken
except ImportError:
raise ImportError(tiktoken_import_err)
Cache directory resolution from `utils.py:436-450`:
def get_cache_dir() -> str:
# User override
if "LLAMA_INDEX_CACHE_DIR" in os.environ:
path = Path(os.environ["LLAMA_INDEX_CACHE_DIR"])
else:
path = Path(platformdirs.user_cache_dir("llama_index"))
path.mkdir(parents=True, exist_ok=True)
return str(path)
Device inference from `utils.py:583-595`:
def infer_torch_device() -> str:
try:
has_cuda = torch.cuda.is_available()
except NameError:
import torch
has_cuda = torch.cuda.is_available()
if has_cuda:
return "cuda"
if torch.backends.mps.is_available():
return "mps"
return "cpu"
Python version constraints from `pyproject.toml:39`:
requires-python = ">=3.9,<4.0"
Common Errors
| Error Message | Cause | Solution |
|---|---|---|
| `ImportError: tiktoken package not found` | tiktoken not installed | `pip install tiktoken` |
| `ModuleNotFoundError: No module named 'llama_index'` | Package not installed | `pip install llama-index-core` |
| `ValidationError: pydantic` | Pydantic v1 installed instead of v2 | `pip install pydantic>=2.8.0` |
| `RuntimeError: This event loop is already running` | Nested asyncio in notebooks | Ensure `nest-asyncio` is installed (auto-patched by LlamaIndex) |
Compatibility Notes
- Python 3.9: Requires `eval-type-backport` package for type annotation compatibility. The finetuning package (`llama-index-finetuning`) requires Python 3.10+.
- GPU Support: Core package does not require GPU. The `infer_torch_device()` utility auto-detects CUDA, MPS (Apple Silicon), or CPU. PyTorch is only needed for embedding finetuning and local model inference.
- Notebooks: `nest-asyncio` is included as a dependency to handle event loop conflicts in Jupyter environments.
- Windows: Ingestion pipeline multiprocessing uses `spawn` context (not `fork`), ensuring Windows compatibility.
Related Pages
- Implementation:Run_llama_Llama_index_Settings_Configuration
- Implementation:Run_llama_Llama_index_SimpleDirectoryReader_Load_Data
- Implementation:Run_llama_Llama_index_VectorStoreIndex_From_Documents
- Implementation:Run_llama_Llama_index_Index_As_Query_Engine
- Implementation:Run_llama_Llama_index_Query_Engine_Query
- Implementation:Run_llama_Llama_index_StorageContext_Persist
- Implementation:Run_llama_Llama_index_SentenceSplitter_Configuration
- Implementation:Run_llama_Llama_index_DocstoreStrategy_Configuration
- Implementation:Run_llama_Llama_index_IngestionPipeline_Init
- Implementation:Run_llama_Llama_index_IngestionPipeline_Run
- Implementation:Run_llama_Llama_index_IngestionPipeline_Persist
- Implementation:Run_llama_Llama_index_FunctionTool_From_Defaults
- Implementation:Run_llama_Llama_index_ReActAgent_From_Defaults
- Implementation:Run_llama_Llama_index_ReActAgent_Run
- Implementation:Run_llama_Llama_index_AgentOutput_Processing
- Implementation:Run_llama_Llama_index_DatasetGenerator_From_Documents
- Implementation:Run_llama_Llama_index_Evaluator_Init
- Implementation:Run_llama_Llama_index_BatchEvalRunner_Init
- Implementation:Run_llama_Llama_index_BatchEvalRunner_Evaluate_Queries
- Implementation:Run_llama_Llama_index_EvaluationResult_Analysis