Any reason why this wouldn't be working?
import arcpy
import os
basedir = 'C:\\Temp'
gdb_name = 'TestGDB'
gdb = os.path.join(basedir, gdb_name)
if arcpy.Exists(gdb):
arcpy.env.workspace = gdb
else:
gdb = arcpy.CreateFileGDB_management(basedir, gdb_name)
arcpy.env.workspace = gdb
I must not be understanding how .Exists() resolves, for if the gdb already exists, it gives me:
arcgisscripting.ExecuteError: ERROR 000258: Output C:\Temp\TestGDB.gdb already exists
Failed to execute (CreateFileGDB)
If the gdb does not exist, it gives me:
RuntimeError: Object: Error in accessing environment <workspace>