1

This Works

The following python script works when connecting to my dev ArcGIS server, from both the ArcMap python window and the IDLE python GUI/shell running on my dev workstation:

import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))

Works: Prints list of all the feature classes in the Enterprise GeoDB


This Does NOT Work

The following python script, which is the same as above but aside from the env.workspace value, DOES NOT work when connecting to my prod ArcGIS server from the IDLE python GUI/shell running on that same ArcGIS server, but DOES work from the ArcMap python window on that server...

When run from ArcMap 10.2.1 python window:

import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))

Works: Prints list of all the feature classes in the Enterprise GeoDB


When run from IDLE python GUI/shell:

import arcpy
arcpy.env.workspace = "Database Connections/Connection to 172.20.0.XX.sde"
str(arcpy.ListFeatureClasses("*"))

Fails: Prints 'None'


The Windows user I'm logged into the prod ArcGIS server with is an admin, but The only thing I can come up with is

Notes

Note I have tried all of the following variations when setting the workspace:

  • arcpy.env.workspace = r"Database Connections\Connection to 172.20.0.49.sde"
  • arcpy.env.workspace = "Database Connections\Connection to 172.20.0.49.sde"
  • arcpy.env.workspace = "Database Connections" + os.sep + "Connection to 172.20.0.49.sde"
  • arcpy.env.workspace = os.path.join("Database Connections", "Connection to 172.20.0.49.sde")
  • Etc...
  • 2
    Is the password saved in the .SDE file or do you get a login dialog in ArcMap? – Jason Scheirer Oct 22 '14 at 22:17
  • I think this is similar to gis.stackexchange.com/questions/5540/… – PolyGeo Oct 22 '14 at 22:22
  • Just test if the workspace is found, like : arcpy.Exists(arcpy.env.workspace). – Neil Ayres Oct 23 '14 at 5:44
  • > Jason, no login dialog in ArcMap. > PolyGeo, yes, step 2 of blah238's post was the solution... full path. > Neil, I had tried that, it was not finding the workspace. I would like to understand why this was happening: the IDLE python shell can't resolve or access the same relative path that the ArcMap python window can... – FlashJordan Oct 23 '14 at 16:14
2

The answer which I found yesterday, and PolyGeo referenced in his comment above, was to use the full path to the sde instead of the relative path. I still don't understand why the IDLE GUI/shell can't use the relative path when the ArcMap python window can.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.