Hello,
I'm new to using arcpy and I'm running into a few complications in getting a model to launch automatically using a python script. I've created the model, tested it, and it works perfectly. However, when I try to launch the model from python, it does not work. I've tried two methods. I've attached relevant documents.
1) Model_ExecuteModelV5.py contains the script used to import the toolbox, and run the model. (the model has no parameters). I've tested the script and I get the printed "Complete". However when I look at my results, the model did not run properly. In this case it did not identify any QC errors which the batch file in the model should have identified. Again, when I test the model within ArcGIS Desktop or Catalog, it works.
2) Model_ExecuteModelV7.py contains the script with the exported model. I exported the model to a .py file and tested that within python. As a result I received an error saying:
AttributeError: 'module' object has no attribute 'ExecuteReviewerBatchJob_Reviewer'
Any support would be greatly appreciated.
Solved! Go to Solution.
Most of the errors I encountered were from field calculators containing VB script. I changed them all to python and it worked.
This is because Windows is set up to associate .py files with the last version of Python installed, in the case of ArcGIS Desktop, this usually means the background processing 64 bit version of Python. So when you run a .py file from task scheduler it will always run x64 python unless you set it up otherwise by prefixing the python script name with C:\Python27\ArcGIS10.2\python.exe to force it to run x32.
The default (VB) parser used by Calculate Field is not supported in arcpy x64. I have totally gotten into the habit of using the Python syntax so my scripts will run in x32 and x64.
My model also doesn't contain parameters. I was able to get model builder to run through python. From there I placed the python script in windows task scheduler. Here is the link I found helpful Scheduling a Python script or model to run at a prescribed time | ArcGIS Blog
below is the python code i used to reference in my model. Most of the errors I encountered were from field calculators containing VB script. I changed them all to python and it worked.
import arcpy import os arcpy.env.overwriteOutput = True arcpy.ImportToolbox(r"E:\GIS\Data\GIS\Dept\TechServices\MyNeighborhood\My Neighborhood.tbx") arcpy.MyNeighbor_MyNeighborhoodtbx
.04 I add the path to the toolbox copied from ArcCatalog
.05 call out the model name "MyNeighborhood" followed by an _ (must included the underscore) then call out the alias name of the toolbox "MyNeighborhoodtbx"
Hope this helps
Most of the errors I encountered were from field calculators containing VB script. I changed them all to python and it worked.
This is because Windows is set up to associate .py files with the last version of Python installed, in the case of ArcGIS Desktop, this usually means the background processing 64 bit version of Python. So when you run a .py file from task scheduler it will always run x64 python unless you set it up otherwise by prefixing the python script name with C:\Python27\ArcGIS10.2\python.exe to force it to run x32.
The default (VB) parser used by Calculate Field is not supported in arcpy x64. I have totally gotten into the habit of using the Python syntax so my scripts will run in x32 and x64.
This topic is cross-posted here
Meta - FYI - to all -
The best method for cross - posting in Geonet is not to create another thread but to open the thread (by clicking its title) and using the Share button on the right side of the page.
Thanks Curtis!
The script runs just fine now. I didn't even think about the 64-bit.