Select to view content in your preferred language

Python env broken at Pro 2.6?

1461
4
Jump to solution
07-29-2020 04:16 PM
MarkCederholm
Frequent Contributor

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.

0 Kudos
1 Solution

Accepted Solutions
CooperLogan
Esri Contributor

Hi Mark Cederholm‌, and others seeing this issue!

The issue has been logged as a defect with Pro 2.6

Thanks!

Cooper

View solution in original post

0 Kudos
4 Replies
MarkCederholm
Frequent Contributor

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..........

0 Kudos
FC_Basson
MVP Regular Contributor

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.

0 Kudos
MarkCederholm
Frequent Contributor

I still see the problem at 2.6.1.

0 Kudos
CooperLogan
Esri Contributor

Hi Mark Cederholm‌, and others seeing this issue!

The issue has been logged as a defect with Pro 2.6

Thanks!

Cooper

0 Kudos