Different behavior in python scripting

2416
2
Jump to solution
10-14-2015 08:13 AM
AlbertoLaurenti
New Contributor III

Hi all,

I've written a script in which I analyze the TOC content in a selected map document. The analysis produces a list of datasets (table, shapefile, geodatabase fc, raster, mosaic dataset, etc...) in the TOC. If a dataset has missing datasource the information will be also reported.

Python code:

import arcpy

# [.....]

mxd = arcpy.mapping.MapDocument(mxdFilePath)

# [.....]

dtfs = arcpy.mapping.ListDataFrames(mxd)

for dtf in dtfs:

       for dts in arcpy.mapping.ListLayers(mxd, "", dtf):

               if dts.supports("DATASOURCE"):

                       if not arcpy.Exists(dts.dataSource):

                               file.write("\t  Missing datasource!  \n")

                       else:

                               # do something.............


So I've created a Toolbox (tbx), added the script e run it: everything works well.

I've also embedded that script in a Python Toolbox (pyt) and run it: everything works well but Personal Geodatabase feature classes return always a "missing datasource" message, althought the data exist and datasources are correctly set.

Finally, If I run the pyt script as shown here, again everything works well.

So, I do something wrong in my Python Toolbox..... but what? Any help please?

Using Python 2.7.2 and ArcGIS 10.1.

Thanks in advance

1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

By chance, do you have 64-bit Background Geoprocessing installed as well?  Personal geodatabases and Excel tables aren't supported with 64-bit Background Geoprocessing, so sometimes people have problems if it is installed and they have background processing enabled.

View solution in original post

2 Replies
JoshuaBixby
MVP Esteemed Contributor

By chance, do you have 64-bit Background Geoprocessing installed as well?  Personal geodatabases and Excel tables aren't supported with 64-bit Background Geoprocessing, so sometimes people have problems if it is installed and they have background processing enabled.

AlbertoLaurenti
New Contributor III

Yes Joshua, you're right!

I've disabled the Background geoprocessing and the pyt works perfectly.

0 Kudos