cocoindex-io/cocoindex · error · ImportError
pymysql is required for Doris connector DDL operations. Inst
Error message
pymysql is required for Doris connector DDL operations. Install it with: pip install pymysql
What it means
Raised by the Doris connector's lazy _get_pymysql helper when pymysql is missing. pymysql is the sync MySQL-protocol client used for Doris DDL (table creation, schema queries), so DDL paths fail with this actionable ImportError.
Source
Thrown at python/cocoindex/connectors/doris/_target.py:109
try:
import aiohttp # type: ignore[import-not-found]
return aiohttp
except ImportError:
raise ImportError(
"aiohttp is required for Doris connector. "
"Install it with: pip install aiohttp"
)
def _get_pymysql() -> Any:
"""Lazily import pymysql (sync MySQL client for DDL)."""
try:
import pymysql # type: ignore[import-not-found]
return pymysql
except ImportError:
raise ImportError(
"pymysql is required for Doris connector DDL operations. "
"Install it with: pip install pymysql"
)
# ============================================================
# JSON encoder for numpy arrays
# ============================================================
class _NumpyEncoder(json.JSONEncoder):
def default(self, obj: Any) -> Any:
if hasattr(obj, "tolist"):
return obj.tolist()
return super().default(obj)
# ============================================================View on GitHub (pinned to e84aa99b32)
Solutions
- Install pymysql: `pip install pymysql`.
- Verify `python -c "import pymysql"` succeeds.
- Include pymysql (or the cocoindex Doris extra) in your dependency file.
Example fix
// before pip install aiohttp // after pip install aiohttp pymysql
Defensive patterns
Strategy: fallback
Validate before calling
try:
import pymysql # noqa
except ImportError:
raise SystemExit("Run: pip install pymysql") Try / catch
try:
app.update()
except ImportError as e:
if "pymysql" in str(e):
print("pip install pymysql") Prevention
- Install pymysql alongside aiohttp for Doris usage
- Add import smoke tests in CI
- Pin both drivers in the dependency file
When it happens
Trigger: Executing Doris DDL (_execute_ddl_sync) or metadata queries (_query_sync), and even retry classification (_is_retryable_error), without pymysql installed.
Common situations: Fresh environments without the Doris extras; CI installing only core deps; requirements drift after refactors dropping pymysql.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- aiohttp is required for Doris connector. Install it with: pi
- google-cloud-bigquery is required to use the BigQuery connec
- {operation_name} failed after {config.max_retries + 1} attem
- VectorSchemaProvider is required for NumPy ndarray type.
- Invalid vector dimension: {vector_schema.size}
AI-assisted analysis of cocoindex-io/cocoindex@e84aa99b32 (2026-09-08).
Data as JSON: /api/errors/98222efeb6d39b36.
Report an issue: GitHub.