I need set the new created fGDB as current for save all FC:

import arcpy
import os
out_folder_path = arcpy.GetParameterAsText (0)
out_name = arcpy.GetParameterAsText (1)
arcpy.CreateFileGDB_management (out_folder_path, out_name)
arcpy.AddMessage ("fGDB created")
# Set fGDB created as scratch workspace
arcpy.env.scratchGDB = out_folder_path + "/" + out_name + ".gdb"
arcpy.AddMessage ("fGDB set current (scratchGDB)")

But I receive the next error:

Traceback (most recent call last):
  File "H:\Python_ArcGIS_MasterSIG\Proyecto_Final\Codigo\Crear_fGDB.py", line 30, in <module>
    arcpy.env.scratchGDB = out_folder_path + "/" + out_name + ".gdb"
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\geoprocessing\_base.py", line 541, in set_
    self[env] = val
  File "c:\program files (x86)\arcgis\desktop10.5\arcpy\arcpy\geoprocessing\_base.py", line 601, in __setitem__
    ret_ = setattr(self._gp, item, value)
AttributeError: Object: Environment <scratchGDB> cannot be set

Failed to execute (CrearfGDB)

What is the mistake?

  • The scratchGDB property is listed as being "Read Only" and the referenced page's Usage Notes reports The Scratch GDB environment is read-only; you cannot set the location directly.
    – Vince
    Commented Jun 10, 2020 at 2:39

1 Answer 1


As @Vince points out, the scratchGDB environment is read-only. However, you can use arcpy.env.scratchWorkspace instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.