import os import subprocess path_to_file = '/path/to/file' if not os.path.exists(path_to_file): subprocess.call('mkdir {}'.format(path_to_file).split())