When trying to copy a feature class from an SDE connection file to a scratch GDB, the FeatureClassToFeatureClass_conversion works in the ArcMap Python window, but I can't get it to work in a Python script. In ArcMap, the code looks like this:
pathScratchGDB = arcpy.env.scratchGDB + os.path.sep
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")
which results in:
In my Python script I have the exact same code:
pathScratchGDB = arcpy.env.scratchGDB + os.path.sep
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")
which results in:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Python27\ArcGISx6410.3\lib\lib-tk\Tkinter.py", line 1486, in __call__
return self.func(*args)
File "C:\SmartFarm_Tools\python_scripts\SmartFarm_Engine1.py", line 1228, in onLoad
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog", pathScratchGDB, "fcZones", 'fldid_id = ' + str(504) + " and type = 'BW2014'")
File "C:\Program Files (x86)\ArcGIS\Desktop10.3\ArcPy\arcpy\conversion.py", line 1789, in FeatureClassToFeatureClass
raise e
ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000732: Input Features: Dataset C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.zone_catalog does not exist or is not supported
Failed to execute (FeatureClassToFeatureClass).
In the same Python script I am able to successfully run this line of code:
arcpy.FeatureClassToFeatureClass_conversion("C:/SmartFarm_Tools/smartfarm_connection.sde/smartfarm.master.boundary_2015", pathScratchGDB, "fcBound", 'master_id = ' + str(inMasterID))
Has anyone seen this before?
EDIT
The data resides on a PostgreSQL/PostGIS database.
Answer
With Luke's help I was able to determine that it was a 32 vs. 64 bit issue. As a workaround, I wrote a quick script that I call with a 32 bit python.exe using subprocess.Popen
:
Popen([r"C:\Python27\ArcGIS10.3\python.exe", r"C:\Temp_Tools\python_scripts\post2fc.py", "lsCatalogID=" + str(lsCatalogID)], stdout=PIPE)
The code for the post2fc.py looks like this:
import arcpy
inList = arcpy.GetParameterAsText(0)
exec(inList)
arcpy.env.overwriteOutput = True
pathScratchGDB = arcpy.env.scratchGDB + os.path.sep
arcpy.FeatureClassToFeatureClass_conversion("C:/Temp_Tools/temp_connection.sde/temp.master.zone_catalog", pathScratchGDB, "fcZones", 'id IN ' + str(tuple(lsCatalogID)))
No comments:
Post a Comment