Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

The online help for arcpy.mapping.ExportReport says that it has some restrictions on use but does not list 64bit machines amongst them.

I am running the following test from IDLE under ArcGIS 10.1 SP1 (with 64bit Background Geoprocessing installed) on Windows 7 SP1.

I've create a simple test.mxd (one layer called Suburbs in data frame called Layers) and a simple test.rlf (included Suburbs, said Finish to take all defaults, saw report and saved it as *.rlf)

However, this code (more or less straight from the Help example):

import arcpy
mxd = arcpy.mapping.MapDocument(r"C:\temp\test.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
lyr = arcpy.mapping.ListLayers(mxd, "Suburbs", df)[0]
arcpy.mapping.ExportReport(lyr,
                           r"C:\temp\test.rlf",
                           r"C:\temp\test.pdf")
del mxd

throws this error:

Python 2.7.2 (default, Jun 12 2011, 14:24:46) [MSC v.1500 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> ================================ RESTART ================================
>>> 

Traceback (most recent call last):
  File "C:\temp\test.py", line 7, in <module>
    r"C:\temp\test.pdf")
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\utils.py", line 181, in fn_
    return fn(*args, **kw)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\mapping.py", line 515, in ExportReport
    return report_source._arc_object.ExportReport(*gp_fixargs((report_layout_file, output_file, dataset_option, report_title, starting_page_number, page_range, report_definition_query, extent, field_map), True))
RuntimeError: Error in generating report
>>> 

Any thoughts on cause and/or possible workaround are welcome!
(My suspicion is that ExportReport may not be supported on 64bit machines.)

share|improve this question
1  
Doesn't ESRI use Crystal Reports for this? My guess is their library is 32-bit only. Does it work if you use the 32-bit Python executable? –  blah238 Mar 16 '13 at 1:41
    
I'm pretty sure that Crystal Reports was excised and replaced by something open source nut from @JasonScheirer answer you seem to be right about it using a 32-bit library. Is there an easy way to "use the 32-bit Python executable" without uninstalling 64bit background geoprocessing? –  PolyGeo Mar 16 '13 at 2:51
    
It depends on how you're running your script. If you're running it from within ArcGIS, just turn off background processing and it will use the embedded (32-bit) interpreter. If you're running it from the command line, you could specify the full path to the 32-bit python.exe. If you're running it from an IDE (you mentioned IDLE) it might have options to specify the interpreter executable location. I know PyScripter does, but I don't know about IDLE. See also: resources.arcgis.com/en/help/main/10.1/index.html#/… –  blah238 Mar 16 '13 at 3:28
    
Thanks for the ideas - I found the quickest thing was to just create a toolbox and add a Python script tool which I ran with no parameters in the foreground. That worked perfectly. –  PolyGeo Mar 16 '13 at 4:23

1 Answer 1

up vote 7 down vote accepted

It will work on a 64 Bit Machine, yes, but only from the 32 bit Python interpreter. It is documented:

The ExportReport function has a dependency on the ArcMap installation. Therefore, ExportReport can only be executed on machines that have ArcMap installed. ExportReport will not run using stand-alone installations of ArcGIS Engine or ArcGIS for Server. Moreover, ExportReport will not work as a Geoprocessing Service.

64-Bit Background geoprocessing is a stand-alone installation.

share|improve this answer
    
Could this be documented a little more explicitly, please? Also, would this "just work" if I uninstalled ArcGIS 10.1 SP1 for Desktop Background Geoprocessing (64-bit)? –  PolyGeo Mar 16 '13 at 2:48
    
It would just work if you used the python.exe in the C:\Python27\ArcGIS10.1 folder and not the python.exe in the 64-bit install's location. I hope would be an option in the Background Geoprocessing installer's setup to not set Python 64 bit as the default, but apparently not. –  Jason Scheirer Mar 16 '13 at 3:58
    
I found the quickest thing was to just create a toolbox and add a Python script tool which I ran with no parameters in the foreground. That worked perfectly. –  PolyGeo Mar 16 '13 at 4:24

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.