1

I'm trying to geocode a few address using a custom model created. When running the model via model builder all runs perfectly.

Also when running it via the embedded interactive python console in ArcCatalog using the following code it also runs smooth.

>>> arcpy.ImportToolbox("C:\\Users\\jvidin\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcToolbox\\My Toolboxes\\usps_geocoder.tbx","geocoder")
<module 'geocoder' (built-in)>
>>> arcpy.geocoder_geocoder(
... 'gc_01', 
... 'J:/Postal/Postal/99_Geocode/01/composites/composite_1',
... 'J:/Postal/Postal/99_Geocode/01/composites/composite_2',
... 'J:/Postal/Postal/99_Geocode/01/gc.gdb/gc_01'
... )
... 
<Result ''>
>>> 

The problem occurs when trying to run it via IDE using the following code:

import arcpy

arcpy.ImportToolbox("C:\\Users\\jvidin\\AppData\\Roaming\\ESRI\\Desktop10.1\\ArcToolbox\\My Toolboxes\\usps_geocoder.tbx",
                    "geocoder")
try:
    arcpy.geocoder_geocoder('gc_01', 'J:/Postal/Postal/99_Geocode/01/composites/composite_1',
                        'J:/Postal/Postal/99_Geocode/01/composites/composite_2',
                        'J:/Postal/Postal/99_Geocode/01/gc.gdb/gc_01')
except Exception as e:
    print e.message

Generating the following error:

*C:\Users\jvidin\2.7_32_arcpy_pyenv\Scripts\python.exe C:/Users/jvidin/PyCharm_projects/2.7_ArcPy_Rebuild_locators/run_geocoding_model_standalone_stackexchange.py

Process finished with exit code -1073741819 (0xC0000005)*

Model created in arc 10.1 and running with arcpy 32 bits 10.1 python install in a virtual env.

## new edit 12/15/2014 . continuation ...

So i changed a bit my model and my script, this time the model has one and only one exposed parameter and its an inline variable %var% used for outputs paths creation . Script below.

it creates the output .gdb based on argument sbr and sets env.workspace to it. (works) than when it runs arcpy.geocoder2_geocoder(sbr), in egg. sbr = '01' it fails with: Process finished with exit code -1073741819 (0xC0000005) not of much help.

def geocoder(sbr):
    try:
        fgdb = str(sbr) + '.gdb'
        path = "J:/Postal/Postal/99_Geocode/_results/"
        env.workspace = path+fgdb
        print env.workspace
        arcpy.CreateFileGDB_management(path, fgdb)
        arcpy.geocoder2_geocoder(sbr)
    except Exception as e:
        print e.message

really have not clue why it continues to fail, all the outputs of geocode2_geocode() model are setted to same env.workspace created.

The geocode2_geocode() model -> contains 2 composite locators that run one after other.

3

[I'm guessing based on available information]: Your problem is with what you're passing in when running it in a an IDE (outside the app)

try:
    arcpy.geocoder_geocoder('gc_01', 'J:/Postal/Postal/99_Geocode/01/composites/composite_1',
                        'J:/Postal/Postal/99_Geocode/01/composites/composite_2',
                        'J:/Postal/Postal/99_Geocode/01/gc.gdb/gc_01')

In your code snippet, I'm guessing gc_01 is some sort of table or layer input? You have no workspace set. When running this in a stand alone IDE, it doesn't know where gc_01 is. You need to either fully qualify the path to it in the tools input: c:\location\table\gc_01 or set the workspace where this lives, before running the geocode tool: arcpy.env.workspace = "c:\\location\\table"

  • Ok. So gc_01 is a table that im expecting to be created on the fly, similar to the behavior when running as you say "via the app" (does this mean , running via the python console ?) – Jorge Vidinha Dec 11 '14 at 15:07
  • "in the app" = in ArcCatalog/Map as a tool there or within the Python window. Based on your note, my answer might not solve your issue, but try fully qualifying it anyways: "in_memory\\gc_01" – KHibma Dec 11 '14 at 15:12
  • Sorry my mistake, the 'gc_01' first arg of .geocoder() is the table of addresses already existent to be geocoded. Helps ? – Jorge Vidinha Dec 11 '14 at 15:17
  • 2
    same answer. fully qualify it (tell the tool where it lives) – KHibma Dec 11 '14 at 15:38
  • sorry to get back to you so late. tried a few other things but the issue stills ... see my new edits – Jorge Vidinha Dec 15 '14 at 17:17

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.