This line of code use os.mkdir to create sub-directory.
try: os.mkdir(sub_path)
except OSError as e:
print("Could not create dir " + e.strerror)
raise SystemExit
It prompts error on my environment because os.mkdir doesn't make all intermediate-level directories needed to contain the leaf directory, as stated in the Python official documentation. Changing to os.makedirs solves my problem.