{"record":{"id":"c755af9d7bb51def","repo":"OpenBB-finance/OpenBB","slug":"unable-to-import-the-required-module","errorCode":null,"errorMessage":"Unable to import the required module.","messagePattern":"Unable to import the required module\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/economy/openbb_economy/economy_views.py","lineNumber":537,"sourceCode":"    def economy_shipping_chokepoint_info(\n        **kwargs,\n    ) -> tuple[\"OpenBBFigure\", dict[str, Any]]:\n        \"\"\"Maritime Chokepoint Info Chart.\"\"\"\n        # pylint: disable=import-outside-toplevel\n\n        provider = kwargs.get(\"provider\")\n\n        if provider != \"imf\":\n            raise RuntimeError(\n                f\"This charting method does not support {provider}. Supported providers: imf.\"\n            )\n\n        try:\n            from openbb_imf.views.maritime_chokepoint_info import (\n                plot_chokepoint_annual_avg_vessels,\n            )\n        except Exception as e:\n            raise RuntimeError(\"Unable to import the required module.\") from e\n\n        theme = (\n            kwargs.get(\"extra_params\", {}).get(\"theme\")\n            or kwargs.get(\"theme\")\n            or getattr(kwargs[\"charting_settings\"], \"chart_style\", \"dark\")\n        )\n        data = (\n            kwargs.pop(\"data\", None)\n            if \"data\" in kwargs and kwargs[\"data\"] is not None\n            else kwargs.get(\"obbject_item\")\n        )\n        fig = plot_chokepoint_annual_avg_vessels(data, theme=theme)  # type: ignore\n        fig.update_layout(\n            margin=dict(l=25, r=25, t=50, b=0),\n        )\n        content = fig.to_plotly_json()\n\n        content[\"config\"] = dict(responsive=False)","sourceCodeStart":519,"sourceCodeEnd":555,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/economy/openbb_economy/economy_views.py#L519-L555","documentation":"The chokepoint chart lazily imports openbb_imf.views.maritime_chokepoint_info.plot_chokepoint_annual_avg_vessels; any exception during that import (missing openbb-imf package, moved/renamed module after a refactor) is wrapped as RuntimeError('Unable to import the required module.') with the cause chained. It is an environment/packaging error, not a data error.","triggerScenarios":"openbb-imf not installed in the environment (the economy extension is present but the IMF provider package is not); version skew where openbb-economy expects a view function that the installed openbb-imf no longer exposes.","commonSituations":"Partial OpenBB installs (pip install openbb without provider extras), upgrading one extension but not its provider package, or Docker images trimmed of optional dependencies.","solutions":["Install the provider package: pip install openbb-imf.","Align versions: reinstall the openbb platform bundle (pip install -U openbb) so openbb-economy and openbb-imf match.","Inspect the chained exception (except RuntimeError as e: print(e.__cause__)) to confirm whether it is ModuleNotFoundError vs AttributeError on the function name."],"exampleFix":"# before\n# openbb-imf missing\nfig, content = views.economy_shipping_chokepoint_info(**kwargs)  # RuntimeError\n\n# after\n# pip install openbb-imf\nfig, content = views.economy_shipping_chokepoint_info(**kwargs)","handlingStrategy":"try-catch","validationCode":"try:\n    from openbb_imf.views.maritime_chokepoint_info import plot_chokepoint_annual_avg_vessels  # noqa\n    imf_views_ok = True\nexcept Exception:\n    imf_views_ok = False\nassert imf_views_ok, 'openbb-imf not installed or outdated'","typeGuard":null,"tryCatchPattern":"try:\n    fig, content = views.economy_shipping_chokepoint_info(**kwargs)\nexcept RuntimeError as e:\n    if str(e) == 'Unable to import the required module.' and e.__cause__:\n        raise RuntimeError(f'install openbb-imf: {e.__cause__!r}') from e\n    raise","preventionTips":["pip install openbb-imf alongside openbb-economy.","Upgrade the full openbb bundle together, not extension-by-extension.","Smoke-test optional chart imports in CI for the providers you chart."],"tags":["charting","imf","import-error","packaging"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}