You would have to trap for a null record when there is a null value for cityname.while row :
# Process: Copy Features
try:
outFeature = os.path.join(env.workspace, row.CITY_NAME)
print outFeature
arcpy.CopyFeatures_management(row, outFeature)
except arcpy.ExecuteError:
print "failed to write"
row = searchCursor.next()
[You do not have to add toolboxes for system tools. This comes from generating a script from Modelbuilder where this redundant and non-portable line is added.]Geoprocessing tools are designed to work on a whole featureclass or layer, not inside a cursor.Your script will only write one feature to a new featureclass, overwriting any previous featureclass. Is this what you intend?If you want more than one feature written out you would have to rewrite the process to select all the rows that meet an expression as a layer and then copy the layer to a new featureclass. You would need a list of citynames from either running a cursor to collect them or maybe Frequency and then open a cursor to get the list. There is no need to set the output path if you have set the workspace.arcpy.env.overwriteOutput = True
arcpy.Frequency_management(cities_mexico,"in_memory/citList","CITY_NAME")
for row in arcpy.SearchCursor("in_memory/citList"):
arcpy.MakeFeatureLayer(cities_mexico,"temp_lay","CITY_NAME = '"+row.CITY_NAME+"'")
arcpy.CopyFeatures("temp_lay",city)
(I have not run this in a Python window so there may be syntax and case errors in this)