Run into the error on Windows, added assert os.path.exists, double checked the path, run the script as administrator, nothing helped.
Turns out if you add your folders to the Windows Defender's Ransomware Protection, you can no longer use other programs to write there unless you add these programs to the Controlled Folder Access' whitelist.
Solution - check if your folder has been added to the Windows Defender's Ransomware Protection and remove it for faster fix.