Select to view content in your preferred language

Run Model with Python (model created in ArcGIS Pro)

4828
12
Jump to solution
11-06-2018 04:09 PM
MarkRankin1
New Contributor II

Hello All,

I'm getting the error "AttributeError: 'module' object has no attribute 'Step1CrimeDataPrep_CrimeTools'" when trying to run a model from python and the model was created in ArcGIS Pro. 

# Import arcpy module
import arcpy, datetime, sys
from time import strftime

#----------------------------------------------------------------------------


arcpy.ImportToolbox(r"\\prfsgis\giswork\PROJECTS\Crime\Crime.tbx")

arcpy.Step1CrimeDataPrep_CrimeTools()

I've done this process in models created in desktop before but this is my first attempt using models created in Pro.  Do I have to do something different?

Thanks for any help.

Cheers,

Mark Rankin

0 Kudos
12 Replies
MarkRankin1
New Contributor II

Howdy Luke,

Sorry about the delay in answering.  You are absolutely correct when I put C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe in the "Program/scripts" and the path to my python script in "Add arguments" it worked like a dream.  I've tested having a time in the task scheduler and manually starting it from the task scheduler and it works both ways.  I'm running it from my local machine with Windows 10 due to us not having a server we can put ArcGIS Pro on right now so the server OS didn't come into the equation.  I have it setup to "run when weather user is logged on or not" and "run with highest privileges".

Thank you all for your help.  You have all been very informative in helping me get this process automated.  I hope you all have a great weekend.

Cheers,

Mark Rankin

0 Kudos
MarkRankin1
New Contributor II

Oops I forgot to include that I did change the toolbox alias to "CrimeTools" it helped me not get as confused with too many portions just having the word crime in them.

0 Kudos
LeandraGordon
Occasional Contributor II

Did you ever get a solution to running the model in Python itself?
I'm trying to get a Python Toolbox up and running and ApplySymbologyFromLayer isn't working from the Python toolbox but works from a Model so I'm trying that until there is a bug fix from ESRI

I'm trying ->  arcpy.ImportToolbox(r"C:\\Data\\7A_MAPPING\\StyleFeaturesModels.tbx") but the compiler doesn't seem to recognise it.

 

0 Kudos