{"record":{"id":"f6c8bd86a2272935","repo":"run-llama/llama_index","slug":"please-pip-install-pyyaml-f6c8bd","errorCode":null,"errorMessage":"Please pip install PyYAML.","messagePattern":"Please pip install PyYAML\\.","errorType":"exception","errorClass":"ImportError","httpStatus":null,"severity":"error","filePath":"llama-index-core/llama_index/core/output_parsers/utils.py","lineNumber":60,"sourceCode":"\n    json_string = _marshal_llm_to_json(text)\n\n    try:\n        json_obj = json.loads(json_string)\n    except json.JSONDecodeError as e_json:\n        try:\n            # NOTE: parsing again with pyyaml\n            #       pyyaml is less strict, and allows for trailing commas\n            #       right now we rely on this since guidance program generates\n            #       trailing commas\n            json_obj = yaml.safe_load(json_string)\n        except yaml.YAMLError as e_yaml:\n            raise OutputParserException(\n                f\"Got invalid JSON object. Error: {e_json} {e_yaml}. \"\n                f\"Got JSON string: {json_string}\"\n            )\n        except NameError as exc:\n            raise ImportError(\"Please pip install PyYAML.\") from exc\n\n    return json_obj\n\n\ndef parse_code_markdown(text: str, only_last: bool) -> List[str]:\n    # Regular expression pattern to match code within triple-backticks\n    pattern = r\"```(.*?)```\"\n\n    # Regular expression pattern to match code within triple backticks with\n    # a Python marker. Like: ```python df.columns```\n    python_str_pattern = re.compile(r\"^```python\", re.IGNORECASE)\n    text = python_str_pattern.sub(\"```\", text)\n\n    # Find all matches of the pattern in the text\n    matches = re.findall(pattern, text, re.DOTALL)\n\n    # Return the last matched group if requested\n    code = matches[-1] if matches and only_last else matches","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/run-llama/llama_index/blob/afd0fef371831f9bda13e5af7167cf4e981278ab/llama-index-core/llama_index/core/output_parsers/utils.py#L42-L78","documentation":"Error \"Please pip install PyYAML.\" thrown in run-llama/llama_index.","triggerScenarios":"Thrown at llama-index-core/llama_index/core/output_parsers/utils.py:60 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Install PyYAML: `pip install PyYAML`."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"afd0fef371831f9bda13e5af7167cf4e981278ab","analyzedAt":"2026-08-15T05:42:58.429Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}