Then identify which directory it's trying to write to with os.system("pwd") and chmod 777 that directory.