{"record":{"id":"91dba8476849eb73","repo":"cocoindex-io/cocoindex","slug":"snowflake-connector-python-is-required-to-use-the","errorCode":null,"errorMessage":"snowflake-connector-python is required to use the Snowflake connector. Please install cocoindex[snowflake].","messagePattern":"snowflake-connector-python is required to use the Snowflake connector\\. Please install cocoindex\\[snowflake\\]\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/cocoindex/connectors/snowflake/_target.py","lineNumber":337,"sourceCode":"        return _json_encoder(value)\n    if col.encoder is not None:\n        return col.encoder(value)\n    return value\n\n\ndef _encode_row(table_schema: TableSchema[Any], row: _RowValue) -> tuple[Any, ...]:\n    return tuple(\n        _encode_value(col, row.get(col_name))\n        for col_name, col in table_schema.columns.items()\n    )\n\n\n@contextmanager\ndef _connect(config: ConnectionConfig) -> Iterator[Any]:\n    try:\n        import snowflake.connector  # type: ignore[import-not-found]\n    except ImportError as e:\n        raise ImportError(\n            \"snowflake-connector-python is required to use the Snowflake connector. \"\n            \"Please install cocoindex[snowflake].\"\n        ) from e\n\n    kwargs: dict[str, str] = {\n        \"account\": config.account,\n        \"user\": config.user,\n        \"password\": config.password,\n    }\n    if config.warehouse is not None:\n        kwargs[\"warehouse\"] = config.warehouse\n    if config.role is not None:\n        kwargs[\"role\"] = config.role\n\n    conn = snowflake.connector.connect(**kwargs)\n    try:\n        yield conn\n    finally:","sourceCodeStart":319,"sourceCodeEnd":355,"githubUrl":"https://github.com/cocoindex-io/cocoindex/blob/e84aa99b3292c5270a4b313b2a7137ad9ce8ab3b/python/cocoindex/connectors/snowflake/_target.py#L319-L355","documentation":"The Snowflake connector depends on the optional `snowflake-connector-python` package. `_connect` imports it lazily; if missing, it re-raises an ImportError pointing to the `cocoindex[snowflake]` extra. The library deliberately keeps Snowflake support optional to avoid forcing heavy dependencies on all users.","triggerScenarios":"Using any Snowflake target API (table_target / applying actions, which calls `_connect`) in an environment where `snowflake-connector-python` is not installed — i.e. cocoindex installed without the [snowflake] extra.","commonSituations":"Fresh CI/production environments where only `pip install cocoindex` was run; deploying a pipeline that worked locally (where the extra was installed) to a slim Docker image; forgetting to update requirements after adding a Snowflake target.","solutions":["Install the extra: `pip install 'cocoindex[snowflake]'` (or `uv add 'cocoindex[snowflake]'`).","Add cocoindex[snowflake] to requirements.txt / pyproject dependencies so environments get it automatically.","If offline, ensure snowflake-connector-python is vendored/installed from your private index."],"exampleFix":"// before\npip install cocoindex\n// after\npip install \"cocoindex[snowflake]\"","handlingStrategy":"fallback","validationCode":"import importlib.util\nif importlib.util.find_spec(\"snowflake.connector\") is None:\n    raise SystemExit(\"Install the Snowflake extra: pip install 'cocoindex[snowflake]'\")","typeGuard":null,"tryCatchPattern":"try:\n    target = snowflake.table_target(...)\nexcept ImportError as e:\n    if \"cocoindex[snowflake]\" in str(e):\n        raise SystemExit(\"Run: pip install 'cocoindex[snowflake]'\") from e\n    raise","preventionTips":["Pin extras in dependencies: cocoindex[snowflake].","Run a dependency check (importlib.util.find_spec) at app startup.","Keep CI and production images built from the same requirements file."],"tags":["snowflake","dependency","import-error"],"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"}