I'm used to running my scripts directly via Python.exe in the enviornment folder, but after upgrading from 2.5.2 to 2.6, certain arcpy tools are failing* whereas others work fine. It also fails at Pro's Python Command Prompt. But when I run the same script in a Pro session via the Python Window, it works fine. Has anyone else seen this? Is there something new I have to do now? And yes, I re-cloned and rebuilt my environment.
*CreateDomain_management and AddCodedValueToDomain_management. I haven't gotten past those two.
Solved! Go to Solution.
I see the same problem in the default environment. And the plot thickens! Here's a test script I created to duplicate the problem:
import arcpy class DomainTest(object): _sTargetGDB = "C:/apps/Data/UPDM_Migration/AssetPackage_AZGas.gdb" _sBackupGDB = "C:/apps/Data/UPDM_Migration/AssetPackage_UPDM.gdb" _sDomainName = "UNSG_WorkCrew" _sDesc = "UNS Gas work crew" _Values = ["NPL", "UES"] def CreateDomain(self): if arcpy.Exists(self._sBackupGDB): if arcpy.Exists(self._sTargetGDB): arcpy.Delete_management(self._sTargetGDB) arcpy.Copy_management(self._sBackupGDB, self._sTargetGDB) arcpy.CreateDomain_management(self._sTargetGDB, self._sDomainName, self._sDesc, "TEXT", "CODED") return def AddValues(self): for sVal in self._Values: arcpy.AddCodedValueToDomain_management(self._sTargetGDB, self._sDomainName, sVal, sVal) return
Sometimes CreateDomain works and sometime it doesn't. If it works, then DomainTest.AddValues() fails.
The CreateDomain_management error is: ERROR 000192: Invalid value for Domain Name
Failed to execute (CreateDomain).
The AddCodedValueToDomain error is: arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.
ERROR 000800: The value is not a member of AnnotationStatus | AP_All_Classes | AP_Association_Classes | AP_Association_Roles | AP_Association_Semantics | AP_Association_Types | AP_Attribute_Types..........
I found that the arcpy command syntax was the issue.
Replace the following arcpy commands:
arcpy.CreateDomain_management with arcpy.management.CreateDomain
arcpy.AddCodedValueToDomain_management with arcpy.management.AddCodedValueToDomain
This fixed my similar issue.