pathwaycom/pathway · error · ImportError
{e}. Consider installing 'pathway[{extra}]'
Error message
{e}. Consider installing 'pathway[{extra}]' What it means
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.
Source
Thrown at python/pathway/optional_import.py:11
# Copyright © 2026 Pathway
from contextlib import contextmanager
@contextmanager
def optional_imports(extra: str):
try:
yield
except ImportError as e:
raise ImportError(f"{e}. Consider installing 'pathway[{extra}]'")
View on GitHub (pinned to fa2f74a464)
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.
Example fix
# before pip install pathway # ... ImportError: No module named 'weaviate_client'. Consider installing 'pathway[weaviate]' # after pip install 'pathway[weaviate]'
Defensive patterns
Strategy: try-catch
Validate before calling
def extra_installed(extra):
try:
import importlib.util
return importlib.util.find_spec(_extra_modules.get(extra, extra)) is not None
except ImportError:
return False Try / catch
try:
pw.io.weaviate.write(...)
except ImportError as e:
if "Consider installing" in str(e):
raise SystemExit(f"Missing optional dependency: {e}. Run: pip install 'pathway[weaviate]'") from e
raise Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- LEANN connector requires the `leann` package. Please visit h
- Failed to install dependencies
- Column {pseudocolumn} has to contain integers only.
- Column {api.TIME_PSEUDOCOLUMN} cannot contain negative times
- Column {api.DIFF_PSEUDOCOLUMN} can only have 1 and -1 values
AI-assisted analysis of pathwaycom/pathway@fa2f74a464 (2026-08-15).
Data as JSON: /api/errors/2fa8bba951e83cdc.
Report an issue: GitHub.