ArcGIS Pro at 2.4/arcpy- FeatureClassToFeatureClass_conversion does not honor overwriteOutput env setting

08-07-2019 07:35 AM
Frequent Contributor

Hello - I upgraded to Pro to 2.4 yesterday and lo and behold my python scripts for overwriting feature classes using the FeatureClassToFeatureClass_conversion tool no longer honors the arcpy.env.overwriteOutput = True environment setting. 

A whole bunch of my data management scripts depend on this! 

The script now keeps telling me that my feature class already exists.  Of course it does, I'm doing an overwrite.  Or at least I did.

This was working just fine at 2.1, 2.2, 2.3.x  

I can't use Copy for most of my layers because I don't want bring over (in some cases) dozens of related tables....


# Import system modules
import sys, os, arcpy, time, smtplib
from datetime import date, timedelta
from arcpy import env

# Local variables...
message = ""
current_time = time.asctime()
todaysDate =
priorYear = str(todaysDate - timedelta(days=547)) #547
starting_time = time.time()
arcpy.env.configKeyword= "DEFAULTS"
arcpy.env.overwriteOutput = True
arcpy.env.maintainAttachments = False

 env.workspace = r"\\scggisis01pw\\agsfed\\data-store\\VantagePoint\\Data" #\\scggisis01pw\\agsfed
 coordinate_system = r"C:\\StageDbsAE\\CoordinateSystems.gdb\\WebMercator"
 env.outputCoordinateSystem = coordinate_system
 env.geographicTransformations = "NAD_1983_HARN_To_WGS_1984_2"
 for fc in arcpy.ListFeatureClasses():
 outLocation = r"\\scggisis01pw\\agsfed\\data-store\\VantagePoint\\Data\\VpAnno.gdb\\VantagePointLayers" # VantagePoint.gdb\
 outFC = fc[:-4] #neg slice for shapes, 4 from right
 #if outFC != "UtilityBilling":
 print (outLocation + "\\" + outFC)
 #disableFC = outLocation + "\\" + outFC
 arcpy.FeatureClassToFeatureClass_conversion(fc, outLocation, outFC)
 message = message + "\n" + "Added Features: " + outFC
 #message = message + "\n" + "Handeld Indexing: " + disableFC
 # pass
except Exception:
 # If an error occurred, print line number and error message
 import traceback, sys
 tb = sys.exc_info()[2]
 e = sys.exc_info()[1]
 #print "Line %i" % tb.tb_lineno
 message = message + "\n" + "Line %i" % tb.tb_lineno
 message = message + "\n" + str(e)‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
11 Replies
MVP Legendary Contributor
    if arcpy.Exists(out_fc) and arcpy.env.overwriteOutput:

Sometimes a file lock might do it, so you can check to see if the output featureclass exists 'AND' overwriteOutput is True and if they both are, try a Delete.... If it won't delete, then you have other issues.

0 Kudos
Frequent Contributor

I appreciate the response.  Executing the Delete is not an issue and I can easily do that.  However, I shouldn't have to the python 3.16.8 IDLE should honor the environment setting and it's not.  That is the issue.

0 Kudos
Frequent Contributor

My mistake -  the idle is honoring the setting:

import arcpy
from arcpy import env
arcpy.env.overwriteOutput = True

environments = arcpy.ListEnvironments()
# Sort the environment list, disregarding capitalization
for environment in environments:
 # As the environment is passed as a variable, use Python's getattr 
 # to evaluate the environment's value
 env_value = getattr(arcpy.env, environment)
# Format and print each environment and its current setting
 print("{0:<30}: {1}".format(environment, env_value))
0 Kudos
MVP Legendary Contributor

So will delete work? (inconvenient or not) even if the overwrite is working? Or will it not delete?

If it will delete and not overwrite, then that is something that should be reported to tech support.

Python wouldn't even be the issue.

0 Kudos
Frequent Contributor

Really?  Respectfully I disagree because we just ran the exact same thing in python IDLE 2.7.16 with the overwrite environment setting set to true and it works there just fine without having to run a delete first. More - the ArcPro 2.4 GP tool runs and honors the overall GP environment setting, as one would expect.

But to answer your question, yes delete does work in python IDLE 3.6.8, then of course the tool works. This occurs whether running against the default python environment or my updated (arcgis package 1.6.2) cloned environment.

0 Kudos
Frequent Contributor

oh also I can say that the maintainAttachments env var is being honored so there is something somewhere that was missed

0 Kudos
MVP Legendary Contributor
# ArcGIS Pro uses Python 3.6.8




Change the 'arc_pro' portion to match your installation path.  You can compare the version of python with the version of 'arcpy'

The paths should jive, unless there is a cross-over between arcpy and python in your setup

Frequent Contributor

Ok thanks for the info

0 Kudos
Occasional Contributor

I got it fixed....honoring overwrite now

Get Outlook for Android<>

0 Kudos