{"record":{"id":"cebc6e12e75aa668","repo":"reflex-dev/reflex","slug":"failed-to-import-module-import-path-r-for-field","errorCode":null,"errorMessage":"Failed to import module {import_path!r} for {field_name}: {e}","messagePattern":"Failed to import module (.+?) for (.+?): (.+?)","errorType":"exception","errorClass":"EnvironmentVarValueError","httpStatus":null,"severity":"error","filePath":"packages/reflex-base/src/reflex_base/environment.py","lineNumber":200,"sourceCode":"        field_name: The field name.\n\n    Returns:\n        The Plugin subclass.\n\n    Raises:\n        EnvironmentVarValueError: If the value is invalid.\n    \"\"\"\n    if \".\" not in value:\n        msg = f\"Invalid plugin value: {value!r} for {field_name}. Plugin name must be in the format 'package.module.PluginName'.\"\n        raise EnvironmentVarValueError(msg)\n\n    import_path, plugin_name = value.rsplit(\".\", 1)\n\n    try:\n        module = importlib.import_module(import_path)\n    except ImportError as e:\n        msg = f\"Failed to import module {import_path!r} for {field_name}: {e}\"\n        raise EnvironmentVarValueError(msg) from e\n\n    try:\n        plugin_class = getattr(module, plugin_name)\n    except Exception as e:\n        msg = f\"Failed to get plugin class {plugin_name!r} from module {import_path!r} for {field_name}: {e}\"\n        raise EnvironmentVarValueError(msg) from e\n\n    if not isinstance(plugin_class, type) or not issubclass(plugin_class, Plugin):\n        msg = f\"Invalid plugin class: {plugin_name!r} for {field_name}. Must be a subclass of Plugin.\"\n        raise EnvironmentVarValueError(msg)\n\n    return plugin_class\n\n\ndef interpret_plugin_env(value: str, field_name: str) -> Plugin:\n    \"\"\"Interpret a plugin environment variable value.\n\n    Resolves a fully qualified import path and returns an instance of the Plugin.","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/reflex-dev/reflex/blob/45b8ed5ab735f8a56bbb09a42384f030eb0208e7/packages/reflex-base/src/reflex_base/environment.py#L182-L218","documentation":"After splitting the dotted path, interpret_plugin_class_env calls importlib.import_module on the module part; an ImportError is chained into EnvironmentVarValueError with the underlying message. The error tells you exactly which module failed and why.","triggerScenarios":"The module part of the plugin path doesn't exist, isn't installed in the current environment, or itself raises ImportError during import (e.g. a missing dependency inside the plugin module).","commonSituations":"Plugin package not in requirements.txt, plugin written for a different Reflex/Python version, or a transitive dependency missing in prod.","solutions":["Install the plugin package into the environment (uv add / pip install)","Fix the module path spelling in the env var","Read the chained ': {e}' part — it usually names the actual missing module inside the plugin","Verify the plugin imports cleanly: uv run python -c \"import my_plugins.module\""],"exampleFix":"# before\n# REFLEX_PLUGIN=my_plugins.module.MyPlugin (my_plugins not installed)\n# after\nuv add my-plugins\n# or fix path\nREFLEX_PLUGIN=my_app.plugins.module.MyPlugin\n","handlingStrategy":"try-catch","validationCode":"import importlib\nmod, _ = value.rsplit(\".\", 1)\ntry:\n    importlib.import_module(mod)\nexcept ImportError as e:\n    raise SystemExit(f\"plugin module {mod} not importable: {e}\")","typeGuard":"def is_importable_module(dotted: str) -> bool:\n    try:\n        importlib.import_module(dotted)\n        return True\n    except ImportError:\n        return False","tryCatchPattern":"from reflex_base.environment import EnvironmentVarValueError\ntry:\n    plugin_cls = interpret_plugin_class_env(value, \"REFLEX_PLUGIN\")\nexcept EnvironmentVarValueError as e:\n    logger.error(\"plugin load failed: %s\", e)\n    value = \"\"  # run without plugin","preventionTips":["Install plugin packages in the same env as the app","Smoke-test plugin imports in CI"],"tags":["environment","plugin","import","module-not-found"],"backgroundTag":"plugin-import-failed","analyzedSha":"45b8ed5ab735f8a56bbb09a42384f030eb0208e7","analyzedAt":"2026-08-28T19:25:27.644Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}