{"record":{"id":"1a5aca80d54ebde3","repo":"cocoindex-io/cocoindex","slug":"sqlite-vec-is-required-for-vector-support-install","errorCode":null,"errorMessage":"sqlite-vec is required for vector support. Install it with: pip install sqlite-vec","messagePattern":"sqlite-vec is required for vector support\\. Install it with: pip install sqlite-vec","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/sqlite/_target.py","lineNumber":1384,"sourceCode":"        ```\n    \"\"\"\n    managed_conn = connect(database, timeout=timeout, load_vec=load_vec, **kwargs)\n    try:\n        yield managed_conn\n    finally:\n        managed_conn.close()\n\n\ndef _load_sqlite_vec(\n    managed_conn: ManagedConnection, *, ignore_error: bool = False\n) -> None:\n    \"\"\"Load the sqlite-vec extension into a managed connection.\"\"\"\n    try:\n        import sqlite_vec  # type: ignore\n    except ImportError as e:\n        if ignore_error:\n            return\n        raise ImportError(\n            \"sqlite-vec is required for vector support. \"\n            \"Install it with: pip install sqlite-vec\"\n        ) from e\n\n    try:\n        managed_conn._conn.enable_load_extension(True)\n        sqlite_vec.load(managed_conn._conn)\n        managed_conn._conn.enable_load_extension(False)\n        managed_conn._loaded_extensions.add(_VEC_EXTENSION)\n    except sqlite3.OperationalError:\n        if ignore_error:\n            return\n        raise\n\n\n__all__ = [\n    \"ColumnDef\",\n    \"ManagedConnection\",","sourceCodeStart":1366,"sourceCodeEnd":1402,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/sqlite/_target.py#L1366-L1402","documentation":"The connection is configured for vector support, which requires the optional sqlite-vec extension. The package could not be imported (it is not installed), so CocoIndex raises an ImportError pointing to the install command, unless the caller opted to ignore the missing extension.","triggerScenarios":"Declaring a vec0/vector-capable SQLite table target and connecting without the sqlite-vec package installed in the current environment; installing cocoindex without the relevant extras; running in a fresh venv/CI container that lacks the dependency.","commonSituations":"New machine or CI runner where the example works locally but sqlite-vec was never installed; switching Python interpreters/venvs; dependency not pinned in requirements after enabling vector support.","solutions":["Run: pip install sqlite-vec (or install the cocoindex extra that includes it).","If using uv: uv add sqlite-vec, then rebuild/reinstall the environment.","If vector support is not actually needed, remove the vector/vec0 configuration from the table target so the extension is not required."],"exampleFix":"// before (error)\nimport cocoindex\nconn = sqlite_target.connect(...)  # vector table, sqlite-vec missing\n// after\n# pip install sqlite-vec\nconn = sqlite_target.connect(...)","handlingStrategy":"try-catch","validationCode":"import importlib.util\nif importlib.util.find_spec(\"sqlite_vec\") is None:\n    raise SystemExit(\"sqlite-vec not installed; run: pip install sqlite-vec\")","typeGuard":"def sqlite_vec_available() -> bool:\n    import importlib.util\n    return importlib.util.find_spec(\"sqlite_vec\") is not None","tryCatchPattern":"try:\n    conn = connect(...)\nexcept ImportError as e:\n    if \"sqlite-vec\" in str(e):\n        subprocess.run([sys.executable, \"-m\", \"pip\", \"install\", \"sqlite-vec\"], check=True)\n        conn = connect(...)","preventionTips":["Pin sqlite-vec in requirements/pyproject whenever vector tables are used.","Check dependencies in CI before running vector pipelines.","Install cocoindex extras rather than bare cocoindex when using vectors."],"tags":["sqlite","sqlite-vec","dependency","import"],"backgroundTag":"missing-optional-dependency","analyzedSha":"e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b","analyzedAt":"2026-09-08T15:59:19.997Z","contentChangedAt":"2026-09-08T15:59:19.997Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}