I came across this problem when tring to access some layers in the enterprise database (Oracle). The codes are written as:

cwd = sys.path[0]

# Process: Create Database Connection
DBConnFile_Name = "Enterprise.sde"
DBConnFile = os.path.join(cwd, DBConnFile_Name)

    "<instance name here>",
    "<username here>",
    "<password here>",

# Get the enterprise database layers
in_Council_Pg = os.path.join(DBConnFile, "DISTRICT_COUNCIL")
in_CrimePrev_Pg = os.path.join(DBConnFile, "DISTRICT_CRIME_PREVENT")
in_ZIP_Pg = os.path.join(DBConnFile, "ZIP")
in_Neighborhood_Pg = os.path.join(DBConnFile, "NEIGHBORHOOD")

I want to use those layers in enterprise database for further processing using other ArcPy functions. When I use the layers saved at local directory as arguments, the entire program runs perfectly fine. But when I try to use the layers in SDE as arguments, Windows tells me that "pythonw.exe has stopped working". One of the functions is written as:

# Process: Spatial Join - Council Districts

print "Stops here."

The programs fails at the function before printing "Stops here".

Do anybody have similar issue?

  • Are you sure it's failing on one of those 4 lines at the end? Or is it after that? Those 4 lines aren't actually doing anything (there's no connection to any files), it's just constructing a path variable. Try putting those lines before the arcpy.CreateDatabaseConnection_management() and see if/where it fails again – Midavalo Mar 17 '17 at 16:06
  • Thank you for replying, @Midavalo. I tried, but it still fails. There're functions afterwards use the path variables as arguments. – PacmanKX Mar 17 '17 at 16:18
  • Where does it fail? Try adding print statements after the 4 lines, eg print in_Neighborhood_pg etc. to show that they've created paths. Or is it failing at the next functions? – Midavalo Mar 17 '17 at 16:20
  • I inserted print statement at multiple places and it fails at the first function uses one of those 4 variables as argument. The function is written as: 'arcpy.SpatialJoin_analysis(<input point layer>, in_Council_Pg, <output point layer>, "JOIN_ONE_TO_ONE", "KEEP_ALL", "", "WITHIN", "", "")' – PacmanKX Mar 17 '17 at 16:29
  • Can you confirm that it passes the print statements and fails on the next function? Please include that function in your code snippet as the issue may be related to that function – Midavalo Mar 17 '17 at 16:42