pola-rs/polars · error
activate 'binary_encoding' feature
Error message
activate 'binary_encoding' feature
What it means
StringNameSpaceImpl::hex_decode is a stub when the binary_encoding feature is off: calling it panics with a message to recompile polars with 'binary_encoding' enabled, since hex decoding is feature-gated.
Solutions
- Enable the feature: cargo add polars --features binary_encoding
- In Python polars, install/upgrade to a build that includes hex decode support
- Rebuild with cargo build --features binary_encoding
- Check feature flags via polars metadata before using hex_decode
Example fix
// before
polars = { version = "0.x" }
// after
polars = { version = "0.x", features = ["binary_encoding"] } Defensive patterns
Strategy: type-guard
Validate before calling
// Python import polars as polars; print(polars.build_info()) # verify feature set // Rust: gate usage on cfg cfg!(feature = "binary_encoding")
Type guard
// Rust
#[cfg(not(feature = "binary_encoding"))]
compile_error!("hex_decode requires the binary_encoding feature"); Try / catch
std::panic::catch_unwind(|| frame.str_hex_decode()); // not recommended; enable the feature instead
Prevention
- Declare required features in Cargo.toml of your crate
- Check wheel/build feature lists before using str namespace hex/binary methods
- Add compile-time cfg assertions for optional features
When it happens
Trigger: Calling df.select(col('a').str.hex_decode()) (or .str.hex_decode equivalents) on a build without feature binary_encoding enabled.
Common situations: Using default Cargo features or a prebuilt wheel without binary_encoding; Python users on builds lacking the feature; transitive dependency pinning features off.
Related errors
- activate 'object' feature
- activate 'propagate_nans'
- activate 'decompress' feature
- activate dtype-categorical to convert dictionary arrays
- activate feature dynamic_group_by
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/452f29c8e15443b9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-ops/src/chunked_array/strings/namespace.rs:108
},
};
polars_bail!(
ComputeError:
"strict integer parsing failed for {} value(s): {}; error message for the \
first shown value: '{}' (consider non-strict parsing)",
n_failures,
some_failures.into_series().fmt_list(),
some_error_msg
);
}
Ok(out.into_series())
}
pub trait StringNameSpaceImpl: AsString {
#[cfg(not(feature = "binary_encoding"))]
fn hex_decode(&self) -> PolarsResult<StringChunked> {
panic!("activate 'binary_encoding' feature")
}
#[cfg(feature = "binary_encoding")]
fn hex_decode(&self, strict: bool) -> PolarsResult<BinaryChunked> {
let ca = self.as_string();
ca.as_binary().hex_decode(strict)
}
#[must_use]
#[cfg(feature = "string_encoding")]
fn hex_encode(&self) -> StringChunked {
let ca = self.as_string();
ca.apply_values(|s| hex::encode(s).into())
}
#[cfg(not(feature = "binary_encoding"))]
fn base64_decode(&self) -> PolarsResult<StringChunked> {
panic!("activate 'binary_encoding' feature")View on GitHub (pinned to fe841f959e)