arcpy.ExtractData_production does not work in Python GUI?

4021
11
03-26-2014 07:05 AM
ThomasColson
MVP Frequent Contributor
>>> arcpy.ExtractData_production("'C:\\Temp\\Python\\GRSM_20140326075058.gdb\\Boundaries_And_AOIs\\grsm_bndry_polygon'","C:\\Temp\\Python\\GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")

 
<Result 'C:\\Temp\\Python\\GRSM_20140326075333.gdb'>



Works fine in the Arc Map Python window.

Per the ESRI help for Extract Data (Production Mapping) one could conclude that

>>> import arcpy
>>> arcpy.CheckOutExtension("Foundation")
u'CheckedOut'
>>> arcpy.ExtractData_production("C:/Temp/Python/GRSM_20140326075058.gdb/Boundaries_And_AOIs/grsm_bndry_polygon","C:/Temp/Python/GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")


Would work as well in Python Shell.

Nope.

Traceback (most recent call last):
  File "<pyshell#26>", line 1, in <module>
    arcpy.ExtractData_production("C:/Temp/Python/GRSM_20140326075058.gdb/Boundaries_And_AOIs/grsm_bndry_polygon","C:/Temp/Python/GRSM_20140326075333.gdb","DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
AttributeError: 'module' object has no attribute 'ExtractData_production'


Tried numerous variations of back, forward, double-slash as per http://resources.arcgis.com/en/help/main/10.1/index.html#//002z0000000r000000

None worked.

So what special trick is required to get arcpy.ExtractData_production to work in Python Shell?
Tags (2)
0 Kudos
11 Replies
JamesCrandall
MVP Frequent Contributor
Just a shot in the dark, but maybe problem is with escape characters in your string paths?  Or perhaps not having the extension available?  Not sure but you can deal with these possible issues:


in_ds = r'C:\Temp\Python\GRSM_20140326075058.gdb\Boundaries_And_AOIs\grsm_bndry_polygon'
target_db = r'C:\Temp\Python\GRSM_20140326075333.gdb'

### see if spatial analyst extension is available for use
availability = arcpy.CheckExtension("Foundation")
if availability == "Available":
   arcpy.CheckOutExtension("Foundation")
   arcpy.AddMessage("Foundation Ext checked out")
else:
   arcpy.AddError("%s extension is not available (%s)"%("Foundation Extension",availability))
   arcpy.AddError("Please ask someone who has it checked out but not using to turn off the extension")
   return

arcpy.ExtractData_production(in_ds,target_db,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")

#return the extension
arcpy.CheckInExtension("Foundation")

0 Kudos
ThomasColson
MVP Frequent Contributor
I was unable to get

availability = arcpy.CheckExtension("Foundation")
if availability == "Available":
   arcpy.CheckOutExtension("Foundation")
   arcpy.AddMessage("Foundation Ext checked out")
else:
   arcpy.AddError("%s extension is not available (%s)"%("Foundation Extension",availability))
   arcpy.AddError("Please ask someone who has it checked out but not using to turn off the extension")
   return


to work however:

>>> arcpy.CheckOutExtension("Foundation")
u'CheckedOut'
>>> arcpy.CheckInExtension("Foundation")
u'CheckedIn'


works fine. I'm running a checked-out license enviroment, and this workstation has every extension and license checked out to it, and all tool in all toolboxes work fine with no license issues.


Trans = r'C:\Temp\Python\GRSM_20140326075058.gdb\Boundaries_And_AOIs\grsm_bndry_polygon'
TarGDB = r'C:\Temp\Python\GRSM_20140326075333.gdb'
arcpy.ExtractData_production(Trans,TarGDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")



still fails with:

Traceback (most recent call last):
  File "C:\Temp\Python\GRSM.PY", line 17, in <module>
    arcpy.ExtractData_production(Trans,TarGDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
AttributeError: 'module' object has no attribute 'ExtractData_production'


I've put this in a .py file, so there are no carraige return or escape issues, same result.


>>> Trans = r'C:\Temp\Python\GRSM_20140326075058.gdb\Boundaries_And_AOIs\grsm_bndry_polygon'
>>> Trans
'C:\\Temp\\Python\\GRSM_20140326075058.gdb\\Boundaries_And_AOIs\\grsm_bndry_polygon'
>>> TarGDB = r'C:\Temp\Python\GRSM_20140326075333.gdb'
>>> TarGDB
'C:\\Temp\\Python\\GRSM_20140326075333.gdb'
>>> arcpy.ExtractData_production(Trans,TarGDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
Traceback (most recent call last):
  File "<pyshell#7>", line 1, in <module>
    arcpy.ExtractData_production(Trans,TarGDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
AttributeError: 'module' object has no attribute 'ExtractData_production'
0 Kudos
JamesCrandall
MVP Frequent Contributor
I don't have this Foundation extension to be able to test but if it works in your ArcMap/Python environment but not in a PythonIDE, then perhaps an environment variable is confusing you IDE install somehow.  That is, the Python executing from ArcMap is using the correct Python.exe install but your standalone copy is not.

Just a guess really.
0 Kudos
ThomasColson
MVP Frequent Contributor
C:\Python27\ArcGISx6410.1\pythonw.exe "C:\Python27\ArcGISx6410.1\Lib\idlelib\idle.pyw" is what I'm using for standalone. Further testing reveals that ALL of the production mapping tools return this error, I am able to run other tools just fine in standalone python. Production mapping tools run fine in Arc Map, as a tool, or Arc Map python window.

Has ESRI perhaps disabled execution of Production Mapping tools in standalone python in Arc Map 10.1?

I'm able to reproduce this on many different workstations.
0 Kudos
ThomasColson
MVP Frequent Contributor
This has been resolved with the application of the latest 10.1 SP1 QIP service pack.
0 Kudos
ThomasColson
MVP Frequent Contributor

And now with the installation of Mapping and Charting Solutions 10.2.2 Patch 2 | Samples and Utilities the same error is produced once again with ArcMap 10.2.2. Really frustrated with how every version and patch from ESRI continually breaks things that reasonably would be stable through releases.....

Traceback (most recent call last):
  File "X:\GIS_Final\data\basedata\basemap\Data\Working\Python_Automated_Scripts\GRSMHYDRO.py", line 39, in <module>
    arcpy.ExtractData_production("X:\\GIS_Final\\data\\basedata\\basemap\\Data\\Working\\Python_Automated_Scripts\\GRSM.sde\\GRSM.DBO.Boundaries_And_AOIs","USE_FILTERS", GDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")
AttributeError: 'module' object has no attribute 'ExtractData_production'

0 Kudos
ChrisWelch1
New Contributor

Does anyone know if there's been any movement on this? We're using 10.2.1 and getting the same problems. Even when I point the script to the proper toolbox, I get the error:

ERROR 000617: Error accessing tool Extract Data

Failing an actual fix for this, does anyone know of a decent way to replicate the speed of Extract Data in the ArcPy environment? Clip works, but it's far slower than Extract Data.

0 Kudos
ThomasColson
MVP Frequent Contributor

No, as of 10.5.1 this is still not working.

0 Kudos
JamesCrandall
MVP Frequent Contributor

Maybe a path issue? Try,

outputWS = r'X:\GIS_Final\data\basedata\basemap\Data\Working\Python_Automated_Scripts\GRSM.sde'
outputName = r'GRSM.DBO.Boundaries_And_AOIs'
inputFC = os.path.join(outputWS, outputName)
 
arcpy.ExtractData_production(inputFC,"USE_FILTERS", GDB,"DO_NOT_REUSE","NO_FILTER_BY_GEOMETRY","INTERSECTS","")   ‍‍‍‍‍
0 Kudos