I was working on a tool the other day. It was something along the lines of :
arcpy.env.workspace = arcpy.management.CreateFileGDB(r"C:\\Documents", "Example")
I got an error
arcpy.env.workspace = arcpy.management.CreateFileGDB(fol, "Example")
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 564, in set_
self[env] = val
~~~~^^^^^
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 640, in __setitem__
ret_ = setattr(self._gp, item, value)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Object: Error in accessing environment <workspace>
However,
arcpy.env.workspace = str(arcpy.management.CreateFileGDB(fol, "Example"))
works just fine.
CreateFileGDB returns a workspace object. It stands to reason arcpy.env.workspace should be able to consume it.
Please let arcpy.env.workspace take workspace objects.