When I run this part of my code, I get an error that says the parameters of the MakeFeatureLayer are not valid. However, when I run the first half of this script (the first try/except) and then run only the second part of the script, the code works, but errors if I run it all together. I'm guessing it is a workspace issue, but I can't figure it out.
import arcpy import math arcpy.env.overwriteOutput = True pth = "C:/Users/Dane/Desktop/Everything/PSU/GEOG_596A/" outname = "Family_" + arcpy.GetParameterAsText(0) + ".gdb" arcpy.GetParameterAsText(0) + ".gdb" arcpy.CreateFileGDB_management(pth, outname, "CURRENT") wkspce = "C:/Users/Dane/Desktop/Everything/PSU/GEOG_596A/master_data" arcpy.env.workspace = wkspce try: fcs = arcpy.ListFeatureClasses() for fc in fcs: arcpy.FeatureClassToGeodatabase_conversion(fc, pth + outname) except: print arcpy.GetMessages() pth1 = "C:/Users/Dane/Desktop/Everything/PSU/GEOG_596A/" outname1 = "Family_" + arcpy.GetParameterAsText(0) + ".gdb" param1 = arcpy.GetParameterAsText(0) famloc = "family_location_" family = "Featured_Family_Location_updated"
arcpy.env.workspace = pth1 + outname1
try: defquery = '"Family_ID" = ' + "'" + param1 + "'" featurein = pth1 + outname1 + "/" + family layer = "family_lyr" copyname = pth1 + outname1 + "/" + famloc + param1 arcpy.MakeFeatureLayer_management(featurein,layer,defquery) arcpy.CopyFeatures_management(layer, copyname) except: print arcpy.GetMessages() ##
This is the error :
ERROR 000732: Workspace or Feature Dataset: Dataset C:/Users/Dane/Desktop/Everything/PSU/GEOG_596A/Family_C:/Users/Dane/Desktop/Everything/PSU/GEOG_596A/master_data\tracts.shp.gdb does not exist or is not supported Failed to execute (MakeFeatureLayer).