Using Data Interoperability tool Quick Import from command line

1810
10
Jump to solution
11-09-2017 04:20 AM
MihkelMänna
Occasional Contributor

Hi all,

I need to automate downloading features from a WFS service. When using the Quick Import tool from the Data Interoperability toolbox in ArcMap/ArcCatalog, it works fine, but when right-click the successful result, copy it as a Python snippet and use it in a script from command line, it won't work. A generic error message is displayed: RuntimeError: Object: Error in executing tool.

Any ideas how to resolve this? Thanks!

0 Kudos
1 Solution

Accepted Solutions
MihkelMänna
Occasional Contributor

Okay, I stumbled upon a solution myself..

I had the 64-bit Python set as the Python path and tried to use it for Python scripts from command line. However, it did not work for scripts and models that were using Data Interoperability functions. When directing the Python path to 32-bit Python, the scripts worked. So I guess Data Interoperability tools use 32-bit Python in the background and we can also only use 32-bit Python for Data Interoperability scripting...

View solution in original post

10 Replies
BruceHarold
Esri Regular Contributor

Hi

The Python you get from copying the result will have a lot of double quoted parameters bookended by a pair of single quotes, and it will be hard to edit.

Drag your result object into a new Model and save the model in a toolbox, you can run that with a Python script.  Don't forget to set the name and alias properties to get the tool name correct for Python.

0 Kudos
MihkelMänna
Occasional Contributor

Thanks for the reply, Bruce!

It certainly seems that your suggestion should be the way to go but I'm unable to use the model in my Python script. I can use other models and Python scripts from my toolbox but for some reason I cannot use the model with the Quick Import tool. If I list the attributes of the arcpy object after importing my toolbox (with dir(arcpy) or arcpy.__dict__), is does not contain the name of the Quick Import tool (but the names of the other tools and models are listed).

I'm using ArcGIS 10.5.1. Any ideas for a solution?

0 Kudos
DanPatterson_Retired
MVP Esteemed Contributor

Does the data interoperability extension get listed?  I don't know if it needs to be enabled in the script like you have to when running spatial analyst tools in a script

0 Kudos
MihkelMänna
Occasional Contributor

The "interop" module gets listed, as well as the "QuickExport_interop" and "QuickImport_interop" tools/functions. Checking out the extension (arcpy.CheckOutExtension("DataInteroperability")) in the script before importing the toolbox doesn't help, unfortunately..

0 Kudos
BruceHarold
Esri Regular Contributor

Hi

I'm using 10.5.1 too and the pattern works for me.  I attach a TBX and Python script which successfully used Quick Import in a model called from the standalone script.

Unfortunately I have to break the WFS source in the sample as it contains an API key I cannot share, but you can get your own to repair the source:

NZ Chatham Island Island Polygons (Topo, 1:50k) Web Services and API Availability | LINZ Data Servic... 

Note the TBX alias is required.

If your WFS service is simple features only you may not need to check out the extension.

If it still doesn't work and you can share your input service URL log a support call and ask them to check with me.

0 Kudos
MihkelMänna
Occasional Contributor

Thanks for the sample TBX and Python script, Bruce!

However, after inserting my API key in the model and fixing the path to the toolbox in the Python script, I still get the same error: AttributeError: 'module' object has no attribute 'GetChathams_GetChathams' . If I run the same model in ArcGIS, everything works fine. The toolbox import in the script works and "GetChathams" is added as an arcpy attribute, but "GetChathams_GetChathams" is not.

0 Kudos
BruceHarold
Esri Regular Contributor

Hello Mihkel

I don't know what is going on here, I could take some guesses but I think the best thing to do now is log a support call.  The toolbox import is not working.  When you get it resolved please post back here so we can all learn something.

0 Kudos
MihkelMänna
Occasional Contributor

Okay, I stumbled upon a solution myself..

I had the 64-bit Python set as the Python path and tried to use it for Python scripts from command line. However, it did not work for scripts and models that were using Data Interoperability functions. When directing the Python path to 32-bit Python, the scripts worked. So I guess Data Interoperability tools use 32-bit Python in the background and we can also only use 32-bit Python for Data Interoperability scripting...

BruceHarold
Esri Regular Contributor

It isn't Data Interoperability functions that need 32bit Python, it is all ArcGIS 10.x apps, ArcGIS Pro uses 64bit Python, but for that we recommend not using PYTHONPATH to control Python access.

0 Kudos