import tarfile tar = tarfile.open("TarName.tar.gz", "w:gz") tar.add("folder/location", arcname="TarName") tar.close()