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.