reflex-dev/reflex · error · ConfigError
YAML support is not available. Please install PyYAML to use
Error message
YAML support is not available. Please install PyYAML to use this feature.
What it means
ConfigError raised when the PyYAML module cannot be imported while loading a YAML config. The hosting CLI keeps PyYAML as an optional dependency, so YAML config loading fails on environments where it isn't installed.
Source
Thrown at packages/reflex-hosting-cli/src/reflex_cli/core/config.py:219
Args:
yaml_path: The path to the YAML file. Defaults to "cloud.yml" in the current directory.
env: The environment to load the config for.
Returns:
Config: A Config instance with the values from the YAML file.
Raises:
ConfigError: If the YAML file is not found.
"""
if not yaml_path.exists():
raise ConfigError(f"Config file not found at {yaml_path}.")
try:
import yaml
except ImportError as e:
raise ConfigError(
"YAML support is not available. Please install PyYAML to use this feature."
) from e
with yaml_path.open() as file:
data = yaml.safe_load(file)
if env:
data = data.get("env", {}).get(env, {})
data = cls._filter_dict(data)
return cls(_cloud_config_path=yaml_path, **data)
@classmethod
def from_toml(
cls,
pyproject_path: Path = Path.cwd() / "pyproject.toml",
env: str | None = None,
) -> Config:
"""Creates a Config instance from a TOML file.
View on GitHub (pinned to 45b8ed5ab7)
Solutions
- Install PyYAML in the active environment (uv add pyyaml / pip install pyyaml, or reinstall reflex-hosting-cli with its yaml extra)
- Alternatively switch your config to pyproject.toml ([tool.reflex-cloud]) which uses the stdlib tomllib
Example fix
# before: ConfigError: YAML support is not available... config = CloudConfig.from_yaml(path) # after # shell: pip install pyyaml config = CloudConfig.from_yaml(path)
Defensive patterns
Strategy: fallback
Validate before calling
try:
import yaml # noqa: F401
HAS_YAML = True
except ImportError:
HAS_YAML = False
if HAS_YAML:
config = CloudConfig.from_yaml(path)
else:
config = CloudConfig.from_toml(pyproject_path) # or install pyyaml Try / catch
try:
config = CloudConfig.from_yaml(path)
except ConfigError as e:
if "PyYAML" in str(e):
config = CloudConfig.from_toml(Path("pyproject.toml"))
else:
raise Prevention
- Install pyyaml alongside reflex-hosting-cli
- Prefer pyproject.toml config in minimal environments
- Pin extras in your deployment requirements: reflex-hosting-cli[yaml]
When it happens
Trigger: Calling CloudConfig.from_yaml (directly or via from_yaml_or_toml_or_none/read_config) in an environment where the pyyaml package is not installed.
Common situations: Installing reflex-hosting-cli with [no-any-extras] or a stripped dependency set; using a restricted corporate environment where PyYAML is blocked; running in a minimal container.
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
- f"Config file not found at {yaml_path}."
- TOML support is not available. Please use Python 3.11 or lat
- No requirements.txt found.
- reflex.Config.plugins contains plugin(s) that could not be l
- ComputedVar dependencies must be Var instances or var names
AI-assisted analysis of reflex-dev/reflex@45b8ed5ab7 (2026-08-28).
Data as JSON: /api/errors/9a41f557c8c1fccf.
Report an issue: GitHub.