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('01')
<Result ''>
>>>
The problem occurs when trying to run it via IDE using the following code:
The model has one and only one exposed parameter and it is an inline parameter %<param>% used for outputs paths creation .
>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.
Script below.
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.geocoder_geocoder(sbr)
except Exception as e:
print e.message
Really have not clue why it continues to fail, tried many things out of ideias. All the outputs of geocode_geocode() model are setted to same env.workspace created.
The geocode_geocode() model -> contains 2 composite locators that run one after other.
Thanks for support.
Suggest moving this discussion to Model Builder where it will get more visibility.
You may want to try looking for the arcpy messages:
import arcpy try: ... except arcpy.ExecuteError: print(arcpy.GetMessages(0)) except Exception as e: print(e.message)
One thing to keep in mind is that in ArcCatalog any environment settings you set in the application will apply. When running from outside the application, you need to be careful to set those environment settings the way you want them (for example. env.overwriteOutput).
Thanks Curtis,
Did add the excepts mentioned but the script continues to fail with some complex report, i cant figure out.
About the environment settings i made a print of all them. I dont see anything that would cause the crashes in my knowledge . The env.overwriteOutput i think its not important since i'm always creating the .fgdb on the fly but even i added arcpy.overwriteOutput = True
See below the env's table.
newPrecision | : SINGLE |
autoCommit | : 1000 |
XYResolution | : None |
XYDomain | : None |
scratchWorkspace | : None |
cartographicPartitions | : None |
terrainMemoryUsage | : False |
MTolerance | : None |
compression | : LZ77 |
coincidentPoints | : MEAN |
randomGenerator | : 0 ACM599 |
outputCoordinateSystem | : None |
rasterStatistics | : STATISTICS 1 1 |
ZDomain | : None |
transferDomains | : False |
resamplingMethod | : NEAREST@@ |
snapRaster | : None |
projectCompare | : NONE |
cartographicCoordinateSystem : None
configKeyword | : None |
outputZFlag | : Same As Input |
qualifiedFieldNames | : True |
tileSize | : 128 128 |
parallelProcessingFactor | : None |
pyramid | : PYRAMIDS -1 NEAREST DEFAULT 75 NO_SKIP |
referenceScale | : None |
extent | : None |
XYTolerance | : None |
tinSaveVersion | : CURRENT |
nodata | : NONE |
MDomain | : None |
spatialGrid1 | : 0.0 |
cellSize | : MAXOF |
outputZValue | : None |
outputMFlag | : Same As Input |
geographicTransformations | : None |
spatialGrid2 | : 0.0 |
ZResolution | : None |
mask | : None |
spatialGrid3 | : 0.0 |
maintainSpatialIndex | : False |
workspace | : J:/Postal/Postal/99_Geocode/_results/01.gdb |
MResolution | : None |
derivedPrecision | : HIGHEST |
ZTolerance | : None |
scratchGDB | : C:\Users\jvidin\AppData\Local\Temp\2\scratch.gdb |
scratchFolder | : C:\Users\jvidin\AppData\Local\Temp\2\scratch |
packageWorkspace | : J:/Postal/Postal/99_Geocode/_results/01.gdb |
addOutputsToMap | : True |
fail log:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'GpMetadataFunctions, Version=10.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86' or one of its dependencies. The system cannot find the file specified.
File name: 'GpMetadataFunctions, Version=10.1.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at GetManagedType(Char* _assembly, Char* _path, Char* _className)
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Process finished with exit code -1073741819 (0xC0000005)
I just got this error today from 10.2.2 in the middle of running a large intensive process. I wasn't using model builder, this was from a Python script.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'GpMetadataFunctions,
Since some metadata functions are only 32-bit, I tried working around this by running the script with 32 bit python. Maybe you could try that:
c:\Python27\ArcGIS10.2\python.exe myscript.py