“OSError: [Errno 17] File exists” when trying to use os.makedirs [duplicate] June 29, 2023 by Tarik As of Python >=3.2, os.makedirs() can take a third optional argument exist_ok: os.makedirs(mydir, exist_ok=True)