“OSError: [Errno 17] File exists” when trying to use os.makedirs [duplicate]

As of Python >=3.2, os.makedirs() can take a third optional argument exist_ok:

os.makedirs(mydir, exist_ok=True)

Leave a Comment