{"record":{"id":"2fa8bba951e83cdc","repo":"pathwaycom/pathway","slug":"e-consider-installing-pathway-extra","errorCode":null,"errorMessage":"{e}. Consider installing 'pathway[{extra}]'","messagePattern":"(.+?)\\. Consider installing 'pathway\\[(.+?)\\]'","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"python/pathway/optional_import.py","lineNumber":11,"sourceCode":"# Copyright © 2026 Pathway\n\nfrom contextlib import contextmanager\n\n\n@contextmanager\ndef optional_imports(extra: str):\n    try:\n        yield\n    except ImportError as e:\n        raise ImportError(f\"{e}. Consider installing 'pathway[{extra}]'\")\n","sourceCodeStart":1,"sourceCodeEnd":12,"githubUrl":"https://github.com/pathwaycom/pathway/blob/fa2f74a4649b7c5908690cf60137263d8d80de5f/python/pathway/optional_import.py#L1-L12","documentation":"pathway.optional_imports.optional_imports is a contextmanager wrapping imports of optional dependencies. When an ImportError escapes the wrapped block, it is re-raised with a suffix telling you which Pathway optional-extra provides the missing module, e.g. \"No module named 'weaviate'. Consider installing 'pathway[weaviate]'\". It exists so missing optional dependencies surface an actionable message instead of a bare ModuleNotFoundError.","triggerScenarios":"Using a Pathway connector or module that depends on an optional package (weaviate client, tantivy, usearch, etc.) without having installed the corresponding `pathway[extra]` bundle; the with optional_imports('extra'): block around those imports converts the ImportError.","commonSituations":"Installing plain `pip install pathway` and then calling pw.io.weaviate.write or BM25 indexing; a fresh environment/CI image built from a trimmed requirements list; a teammate's lockfile that dropped an optional dependency.","solutions":["Install the suggested extra: pip install 'pathway[weaviate]' (or whichever extra the message names).","Or install the underlying package directly, e.g. pip install weaviate-client, if you do not want the full extra bundle.","Pin the extra in requirements.txt / pyproject.toml so CI and teammates get it automatically."],"exampleFix":"# before\npip install pathway\n# ... ImportError: No module named 'weaviate_client'. Consider installing 'pathway[weaviate]'\n\n# after\npip install 'pathway[weaviate]'","handlingStrategy":"try-catch","validationCode":"def extra_installed(extra):\n    try:\n        import importlib.util\n        return importlib.util.find_spec(_extra_modules.get(extra, extra)) is not None\n    except ImportError:\n        return False","typeGuard":null,"tryCatchPattern":"try:\n    pw.io.weaviate.write(...)\nexcept ImportError as e:\n    if \"Consider installing\" in str(e):\n        raise SystemExit(f\"Missing optional dependency: {e}. Run: pip install 'pathway[weaviate]'\") from e\n    raise","preventionTips":["Declare pathway extras in pyproject dependencies: pathway[weaviate] instead of bare pathway.","Smoke-test each connector import in CI so a missing optional dependency fails the build, not production."],"tags":["pathway","dependencies","installation","import-error"],"backgroundTag":null,"analyzedSha":"fa2f74a4649b7c5908690cf60137263d8d80de5f","analyzedAt":"2026-08-15T01:48:17.006Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}