{"record":{"id":"5d7f6c89641bda50","repo":"chroma-core/chroma","slug":"the-onnxruntime-python-package-is-not-installed-p","errorCode":null,"errorMessage":"The onnxruntime python package is not installed. Please install it with `pip install onnxruntime`","messagePattern":"The onnxruntime python package is not installed\\. Please install it with `pip install onnxruntime`","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py","lineNumber":72,"sourceCode":"        \"\"\"\n        # convert the list to set for unique values\n        if preferred_providers and not all(\n            [isinstance(i, str) for i in preferred_providers]\n        ):\n            raise ValueError(\"Preferred providers must be a list of strings\")\n        # check for duplicate providers\n        if preferred_providers and len(preferred_providers) != len(\n            set(preferred_providers)\n        ):\n            raise ValueError(\"Preferred providers must be unique\")\n\n        self._preferred_providers = preferred_providers\n\n        try:\n            # Equivalent to import onnxruntime\n            self.ort = importlib.import_module(\"onnxruntime\")\n        except ImportError:\n            raise ValueError(\n                \"The onnxruntime python package is not installed. Please install it with `pip install onnxruntime`\"\n            )\n        try:\n            # Equivalent to from tokenizers import Tokenizer\n            self.Tokenizer = importlib.import_module(\"tokenizers\").Tokenizer\n        except ImportError:\n            raise ValueError(\n                \"The tokenizers python package is not installed. Please install it with `pip install tokenizers`\"\n            )\n        try:\n            # Equivalent to from tqdm import tqdm\n            self.tqdm = importlib.import_module(\"tqdm\").tqdm\n        except ImportError:\n            raise ValueError(\n                \"The tqdm python package is not installed. Please install it with `pip install tqdm`\"\n            )\n\n    # Borrowed from https://gist.github.com/yanqd0/c13ed29e29432e3cf3e7c38467f42f51","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/chroma-core/chroma/blob/aecdd12c8a891610db8653630b066b32ceb678b5/chromadb/utils/embedding_functions/onnx_mini_lm_l6_v2.py#L54-L90","documentation":"ONNXMiniLM_L6_V2 imports onnxruntime lazily via importlib.import_module(\"onnxruntime\") in __init__ and wraps ImportError in a ValueError with install instructions. This class is Chroma's default local embedding function, so hitting this means the chromadb default-extra dependency chain (onnxruntime, tokenizers, tqdm) is not installed in the current environment. Everything else in the constructor (model download, tokenizer setup) depends on this module.","triggerScenarios":"Instantiating ONNXMiniLM_L6_V2() or letting Chroma use its default EF after a bare `pip install chromadb` without extras in an env that also lacks onnxruntime; a fresh CI image; installing chromadb with `--no-deps`; a venv where onnxruntime was uninstalled during a dependency-resolver conflict (it conflicts with onnxruntime-gpu since both provide the same package name).","commonSituations":"Docker slim images that trimmed \"heavy\" dependencies; installing onnxruntime-gpu alongside onnxruntime and pip removing one; version pinning tools (pip-tools/poetry) resolving onnxruntime out; upgrading Python versions and reinstalling only chromadb.","solutions":["pip install onnxruntime (or reinstall chromadb with its default extras: pip install 'chromadb' which pulls onnxruntime>=1.14.1)","If you need GPU, install onnxruntime-gpu INSTEAD of onnxruntime — both register the same import name and cannot coexist","Verify the install is in the right interpreter: python -c \"import onnxruntime; print(onnxruntime.__version__)\""],"exampleFix":"// before\nfn = ONNXMiniLM_L6_V2()  # ValueError: onnxruntime not installed\n\n// after (shell)\npip install onnxruntime\n# or for GPU: pip uninstall onnxruntime && pip install onnxruntime-gpu\n// then\nfn = ONNXMiniLM_L6_V2()","handlingStrategy":"validation","validationCode":"import importlib.util\nif importlib.util.find_spec(\"onnxruntime\") is None:\n    raise SystemExit(\"onnxruntime missing: pip install onnxruntime (or onnxruntime-gpu)\")\nfn = ONNXMiniLM_L6_V2()","typeGuard":null,"tryCatchPattern":"try:\n    ef = ONNXMiniLM_L6_V2()\nexcept ValueError as e:\n    if \"onnxruntime\" in str(e) and \"not installed\" in str(e):\n        raise SystemExit(\"Install onnxruntime (CPU) or onnxruntime-gpu (NVIDIA) and retry\") from e\n    raise","preventionTips":["Never install onnxruntime and onnxruntime-gpu together — they collide on the same import name","Include chromadb's default extras in Docker images if you rely on the default EF","Add a startup import check for onnxruntime/tokenizers/tqdm in slim deployments"],"tags":["onnx","embedding-function","import-error","dependency","chroma"],"backgroundTag":"missing-dependency","analyzedSha":"aecdd12c8a891610db8653630b066b32ceb678b5","analyzedAt":"2026-08-16T21:53:27.228Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}