Search code examples
pythonyamlpyyaml

Failed to load YAML using PyYaml?


Has anyone ever found an error like this?

File "C:\Python27\lib\site-packages\yaml\parser.py", line 439, in parse_block_mapping_key
"expected <block end>, but found %r" % token.id, token.start_mark)

ParserError: while parsing a block mapping
  in "a.yml", line 1, column 1
expected <block end>, but found '<block mapping start>'
  in "a.yml", line 224, column 2 

I found it when I tried to load a YAML file using PyYaml. I googled it, but I didn't found anything.


Solution

  • The problem is, I didn't get a valid YAML file. At first, I thought my code was wrong, but, after I checked the Online YAML Parser it returned the same output. Assuming that website is right, the YAML file is not valid.