HKUDS/Vibe-Trading · error · ValueError
YAML config is not available because PyYAML is missing
Error message
YAML config is not available because PyYAML is missing
What it means
Raised by _read_config_file when a .yaml/.yml config is requested but the yaml module imported to None, meaning PyYAML is not installed in the environment. The loader supports JSON out of the box; YAML is an optional capability.
Source
Thrown at agent/src/config/loader.py:252
Args:
path: Config file path to decode.
Returns:
The decoded config object as a dictionary.
Raises:
ValueError: If the file format is unsupported, YAML support is
unavailable, or the decoded payload is not an object.
"""
suffix = path.suffix.lower()
text = path.read_text(encoding="utf-8")
if suffix == ".json":
data = json.loads(text)
elif suffix in {".yaml", ".yml"}:
if yaml is None:
raise ValueError("YAML config is not available because PyYAML is missing")
data = yaml.safe_load(text) or {}
else:
raise ValueError(f"Unsupported config file format: {suffix or '<none>'}")
if not isinstance(data, dict):
raise ValueError("Agent config must decode to a JSON/YAML object")
return data
def _merge_agent_config_dicts(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any]:
"""Merge top-level agent config payloads with MCP-aware server replacement."""
non_mcp_override = {key: value for key, value in override.items() if key != "mcp_servers"}
merged = _merge_dicts(base, non_mcp_override)
override_servers = override.get("mcp_servers")
if not isinstance(override_servers, dict):
if "mcp_servers" in override:
merged["mcp_servers"] = override_serversView on GitHub (pinned to 80ffdda44c)
Solutions
- pip install pyyaml (or the project's yaml/config extra if one exists).
- Alternatively convert the config to .json, which needs no extra dependency.
Example fix
# before pip install vibe-trading-ai # no pyyaml # after pip install pyyaml vibe-trading-ai
Defensive patterns
Strategy: validation
Validate before calling
def can_read_yaml_config() -> bool:
import importlib.util
return importlib.util.find_spec('yaml') is not None Try / catch
try:
cfg = load_agent_config(path)
except ValueError as e:
if 'PyYAML is missing' in str(e):
cfg = load_agent_config(json_equivalent_path) Prevention
- Install PyYAML in every environment that touches YAML configs
- Prefer .json configs for minimal deployment targets
- Add a startup probe for optional deps
When it happens
Trigger: Calling load_agent_config with a path ending in .yaml or .yml in an environment without PyYAML installed.
Common situations: Base install without the yaml extra; CI environments trimmed of optional deps; config authored as YAML but deployed to a runtime that only installed core dependencies.
Understand the failure class
Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.
Related errors
- Agent config must decode to a JSON/YAML object
- Feishu QR login requires a JSON agent config; use ~/.vibe-tr
- agent config 'channels' must be an object
- agent config 'channels.feishu' must be an object
- group_message_buffer_size must be > 0
AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28).
Data as JSON: /api/errors/4532c7bef6c2de5b.
Report an issue: GitHub.