I'm trying to execute a model made in ArcGIS outside ESRI environment. I want to import several CSV files to my database

This is my code to import my toolbox/model where:

IJA0101X00006666importcsv: model name
test: toolbox name
import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = r"c:/projet/"
print "Script finished"

In MS DOS I have a message that the script has finished, but when I see the database nothing has changed. Apparently the model didn’t import any data….

Can anyone tell me where the error is?

  • 1
    does your code produce any errors? try adding a print statement after each line and see where it hangs – NULL.Dude Aug 21 '18 at 11:31
  • No error produced I don’t have many knowledge on python that’s why I made all the operations in model builder in ArcGIS Export to Phyton code didn’t work neither because of the errors I don’t know how to solve. I thought this would be the easiest way I just want to launch a model made by me outside ArcGIS environment in order to schedule the operation in windows – Ricardo Mendes Aug 21 '18 at 12:23
  • you can successfully import arcpy outside the ArcGIS environment so your using the same machine that has ArcGIS installed but just running the IDLE terminal? – NULL.Dude Aug 21 '18 at 12:24
  • Booth model/ArcGIS/Data are in same machine In aArcGIS environment I have zero problems, launching the model in python calling //import arcpy I have no problem neither It’s when I go to see the data that the model is supposed to treat that nothing happened – Ricardo Mendes Aug 21 '18 at 12:51
  • what toolbox are you using? its a custom tool? post the code – NULL.Dude Aug 21 '18 at 13:06

You are seeing "Script finished" because it says to print it. There is no try or catch in what you added in for the code. Or any procedures that make sense. The line "arcpy.IJA0101X00006666importcsv_test" would not execute, because it's not valid.

You want to run the model as a python script, only what you shared isn't the model. It appears that what you've copied looks like the results of the model running in the results panel for geoprocessing in ArcMap.

To obtain the python script of the model. 1. Open model in model viewer 2. Go to menu item model 3. Click export, and then export as python script. 4. Save script to a location that you can easily access via command prompt.

(When trying to run this python script, I highly suggest that you write a .bat file and use logging.)

After these steps then you'll have the python script. Keep in mind that doesn't mean that your machine will automatically recognize python functions. You may still need to add an environmental variable to the python.exe.

But first thing first, export the model to python script.


Problem solved The error was in « intermediate data » in the model Model export to .py and works marvelous outside ArcGIS environment Thank a lot for yours answers you are awesome!!!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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