0

AttributeError: 'module' object has no attribute

I have a python script that runs 5 Spatial ETL tools that I wish to run as a scheduled task.

Each of the tools will run successfully from ArcCatalog and also from the ArcCatalog Command line.

If I try to run the tools from the DOS window, as would be done via python script for a scheduled task, arcpy cannot find the tools, although it does load the toolbox.

In the attached screenshot:

  1. I open a cmd.exe window
  2. start python
  3. import arcpy
  4. Import my toolbox, which is verified as loaded on the next line
  5. Use arcpy.ListTools to see what tools are loaded. the result is "[]", meaning no tools are recognized from this tool box
  6. I use the same ListTools to show the Spatial Analyst tools that were loaded by import arcpy
  7. I attempt to execute one of the tools from my toolbox and forget a " (my mistake!)
  8. I attempt to execute one of the tools from my toolbox and receive the message "AttributeError: 'module' object has no attribute 'CopyFeatureClass_newgpetl'".

What is preventing my tools from being recognized from the DOS CMD.EXE window while ArcCatalog and ArcCatalog Command Line can run them?

2 Answers 2

1

Not sure if you figured this out...but I found the same problem when using the 64-bit Python executable. It's unclear which one you're using in that screenshot. The problem did not occur for me when I used the 32-bit python exe. Find the 32-bit python exe in your C:\Python2x folder (it'll be inside a ArcGIS10.x folder, without 'x64' in it), and execute it with a full path, like so:

C:/Python27/ArcGIS10.2/python.exe myscript.py

0

That image is kind of hard for me to read, but I'd say that your custom toolbox is not part of arcpy. The error is trying to say the same thing. Adding a toolbox to ArcTools doesn't make it part of arcpy. You'd have to import it separately. Unfortunately, I've never done that in the way you're set up here, so may not be able to help. Generally, if your tools are in the python file mytools.py, you'd import mytools as well as arcpy. Then call mytools.CopySomething() in your script.

4
  • The toolbox is imported by arcpy.ImportToolbox in step #4.
    – Chris Rado
    Commented Jul 15, 2014 at 17:47
  • Ok, my bad, did not see that. However, you're using regular Windows backslashes in that step, when you should be using forward slashes, double backslashes, or preceding the quote mark with an r.
    – recurvata
    Commented Jul 15, 2014 at 18:59
  • It is also helpful to check out the Data Interoperability extension... arcpy.CheckOutExtension("DataInteroperability"). You can't see Spatial ETL Tools in ArcCatalog unless this extension is checked. I thought his solved the problem- all tools visible and they run on my local machine, but I'm still having the same problem on our server.
    – Chris Rado
    Commented Jul 15, 2014 at 21:32
  • 2
    This is why I couldn't get the tools to run on the server even though they ran on my local machine: Spatial ETL Tools won't run on a machine that has ESRI Production Mapping (or Workflow Manager) installed. This is a known problem, NIM090873.
    – Chris Rado
    Commented Jul 22, 2014 at 18:13

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