OpenBB-finance/OpenBB · error · ImportError

Please install polars: `pip install polars pyarrow` to use

Error message

Please install polars: `pip install polars pyarrow`  to use this method.

What it means

Raised in the economic-indicators validator's dimension cross-check when a supplied country code is not among the dataflow's available country-dimension values, given the already-selected indicator(s). IMF SDMX dimensions are constrained by prior selections, so a code that is globally valid ISO3 can still be invalid for that indicator/dataflow combination. '*' and 'all' are exempted from the check.

Source

Thrown at openbb_platform/core/openbb_core/app/model/obbject.py:292

        except ValueError as ve:
            raise OpenBBError(
                f"ValueError: {ve}. Ensure the data format matches the expected format."
            ) from ve
        except TypeError as te:
            raise OpenBBError(
                f"TypeError: {te}. Check the data types in your results."
            ) from te
        except Exception as ex:
            raise OpenBBError(f"An unexpected error occurred: {ex}") from ex

        return df

    def to_polars(self) -> "PolarsDataFrame":  # type: ignore
        """Convert results field to polars dataframe."""
        try:
            from polars import from_pandas  # type: ignore # pylint: disable=import-outside-toplevel
        except ImportError as exc:
            raise ImportError(
                "Please install polars: `pip install polars pyarrow`  to use this method."
            ) from exc

        return from_pandas(self.to_dataframe(index=None))

    def to_numpy(self) -> "ndarray":
        """Convert results field to numpy array."""
        return self.to_dataframe(index=None).to_numpy()

    def to_dict(
        self,
        orient: Literal[
            "dict", "list", "series", "split", "tight", "records", "index"
        ] = "list",
    ) -> dict[Hashable, Any] | list[dict[Hashable, Any]]:
        """Convert results field to a dictionary using any of Pandas `to_dict` options.

        Parameters

View on GitHub (pinned to 3e071fcc2c)

Solutions

  1. Read the `available values` list in the error message and restrict to those countries.
  2. Query the dataflow's dimension values via the provider's metadata helpers (ImfMetadata / list endpoints) before building the country list.
  3. Use `country='all'` to fetch everything and filter client-side.
  4. Upgrade openbb-imf if the codelist changed upstream.

Example fix

# before
res = obb.economy.economic_indicators(provider='imf', symbol='IFS::NGDP_XDC', country='ATA')

# after
res = obb.economy.economic_indicators(provider='imf', symbol='IFS::NGDP_XDC', country='USA')
Defensive patterns

Strategy: try-catch

Try / catch

try:
    res = obb.economy.economic_indicators(provider='imf', symbol=sym, country=c, frequency=f)
except Exception as e:
    msg = str(e)
    if 'available values are' in msg:
        # dimension cross-check failure: parse the listed values and re-issue
        available = msg.split('available values are:')[-1].strip()
        res = obb.economy.economic_indicators(provider='imf', symbol=sym, country='all', frequency=f)
    else:
        raise

Prevention

When it happens

Trigger: `symbol='IFS::NGDP_XDC', country='ATA'` where Antarctica is not in IFS's REF_AREA values; country codes for territories/aggregates (e.g. 'EMU') that a dataflow doesn't report; a country valid for one indicator but dropped from the codelist for the chosen indicator.

Common situations: Looping a fixed country list over many indicators where coverage differs; using aggregate codes from other endpoints; IMF codelist revisions (version drift between provider metadata and live API).

Related errors


AI-assisted analysis of OpenBB-finance/OpenBB@3e071fcc2c (2026-08-14). Data as JSON: /api/errors/8ef60f0caaf4b638. Report an issue: GitHub.