Solution skill
TypeError: load() missing 1 required positional argument: 'Loader'
Complete solution
Fixes TypeError: load() missing 1 required positional argument: 'Loader' from PyYAML 5.1+. Shows the safe_load replacement and when FullLoader is actually needed. Use when yaml.load with one argument blows up after a PyYAML upgrade. Not for missing-module errors or CLoader import errors.
TL;DR
Since PyYAML 5.1, yaml.load requires a Loader argument (it warns first, then 6.0 made it an error). In almost every case the fix is one word: call yaml.safe_load(stream) instead of yaml.load(stream). Only reach for Loader=yaml.FullLoader if you truly need non-safe constructs.
The error
TypeError: load() missing 1 required positional argument: 'Loader'Fix it
Replace
yaml.load(f)withyaml.safe_load(f)and rerun. Expected: no TypeError; data loads exactly as before for plain dicts/lists/scalarsIf safe_load rejects something you need (python objects, timestamps quirks), use
yaml.load(f, Loader=yaml.FullLoader)instead. Expected: loads with the full (but still unsafe-construct-free) loaderGrep your repo for other bare
yaml.load(calls and fix them all at once. Expected: grep returns no bare yaml.load( calls
When this applies
- TypeError: load() missing 1 required positional argument: 'Loader'
- code written for PyYAML 4.x or older now running on 5.1+
When it does NOT apply
- you actually want the unsafe Loader (rare; think twice, it can execute arbitrary objects)
- CLoader/SafeLoader import errors (different skill)
Tool and version notes
PyYAML 5.1 through 6.x, all supported Pythons. Behavior change landed in 5.1 (warning) and became a hard error in 6.0.
Other ways this shows up
TypeError: load() missing 1 required positional argument: 'Loader' in Ansible or Salt
Same root cause: vendored or pinned old call sites. Fix the call site, dont downgrade PyYAML, since old versions have known deserialization CVEs.
Why it happens
yaml.load without a Loader could construct arbitrary python objects from untrusted input, a real remote-code-execution vector. Upstream made the Loader mandatory so nobody gets the dangerous default by accident.
Edge cases
- safe_load cant load custom python objects on purpose; thats the security boundary, not a bug.
- yaml.unsafe_load exists but you should basically never use it on input you didnt write yourself.
Evidence
A user hit this exact error: TypeError: load() missing 1 required positional argument: 'Loader' (pyyaml). What was asked: how to fix it. The verified fix: Since PyYAML 5.1, yaml.load requires a Loader argument (it warns first, then 6.0 made it an error). In almost every case the fix is one word: call yaml.safe_load(stream) instead of yaml.load(stream). Only reach for Loader=yaml.FullLoader if you truly need non-safe constructs. Source: https://github.com/stanfordnqp/spins-b/issues/81 (gh:stanfordnqp/spins-b#81).
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_D1CLHezNZLx9q0E3TAM3sg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">TypeError: load() missing 1 required positional argument: 'Loader' <span>— Vectle</span></a>